Matlab 2012b: Hiding unassigned variables in the Debug Workspace
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
While it is nice in Matlab 2012b that you can see every workspace variable for a function the moment it goes into debug mode but is there a way to disable seeing all but variables that have values assigned?
I have a function that has 365 elements that may eventually be populated but having to scroll through them all the moment the function is called only to see what is in the first few within a function is a real productivity killer. Especially since the key names are so far apart.
Is there a setting somewhere to show only populated (variables that have values) and not every single little thing?
2 comentarios
per isakson
el 6 de Feb. de 2013
There must be a better way. What do you mean by elements? Not variables? There is no "disable seeing".
Respuestas (2)
Image Analyst
el 6 de Feb. de 2013
If it's not assigned yet, it won't appear in the workspace panel.
If you're talking about a big array that you initialized to all zeros or ones, but only have assigned a few of them to a different number (than 0 or 1 or whatever they got initialized to), then no - it shows the entire array. You could extract out the elements that got assigned into a different array if you want but the indexes of that extracted array would be different than the initial array. For example yourArray = [0 0 0 0 42 73 0 0 ] and extractedArray [42 73] but the indexes for the original values were 5 and 6, while for the extracted array they are 1 and 2.
4 comentarios
Image Analyst
el 7 de Feb. de 2013
Editada: Image Analyst
el 7 de Feb. de 2013
I've never seen that before, but then I don't use "end" to close/finish/terminate functions, which Walter suggested might be the cause of your issue. See if you have an extra "end" to finish off a function and get rid of it like he suggests.
Walter Roberson
el 7 de Feb. de 2013
Editada: Walter Roberson
el 7 de Feb. de 2013
My hypothesis: you have an "end" corresponding to the "function" line, so the routine is a closure. See http://www.mathworks.com/matlabcentral/fileexchange/18223-closures-in-the-matlab-language for more about closures.
As soon as the function begins executing, all of the closure variables are given slots in the closure. Or, in MATLAB terminology, the "static workspace" is created, after which no more variables are permitted to be created.
To get back the other behavior, do not use a closure / static workspace.
Note 1: nested routines and nested variables require closures / static workspaces.
Note 2: any one .m file must be all one or all the other. If there is even one routine that has an "end" matching its "function" line, then all routines in the .m file must also use "end" matching the "function" line.
1 comentario
per isakson
el 7 de Feb. de 2013
Years ago "my" Matlab displayed \<unassigned> like this. At that time nested functions and the static workspace were new. Why not ask the The Mathworks support.
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!