Matlab 2012b: Hiding unassigned variables in the Debug Workspace

1 visualización (últimos 30 días)
Ken
Ken el 6 de Feb. de 2013
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
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".
Ken
Ken el 6 de Feb. de 2013
sorry for the confussion
in this case elements = variables
In 2010, variables and their values during debugging in a step by step process used to only populate the workspace as they were called and assigned during each given step. Now, in 2012b, as soon as the function is called in debugging mode, stopping on first line of code, every single possible variable that could have an assignment in the function appears in the workspace.

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
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
Ken
Ken el 6 de Feb. de 2013
Editada: Ken el 6 de Feb. de 2013
I agree, that is what should be happening but here is a temporary screen shot.
Debug stopped on first line of executable code (certain info blurred for security purposes). Workspace populated as previously stated.
Image Analyst
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.

Iniciar sesión para comentar.


Walter Roberson
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
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.

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by