Variables not appearing in workspace

45 次查看(过去 30 天)
Tomas
Tomas 2013-12-5
回答: Aaron 2023-2-3
I created a MATLAB script that should create some variables, and they only appear in the workspace when i use CRTL+C and finish the programm. I dont think that they're availabe in the progress of the program because it doesn´t work the way it should

回答(4 个)

Image Analyst
Image Analyst 2013-12-5
I bet they are and you just need to view this: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/
  1 个评论
Image Analyst
Image Analyst 2013-12-5
Do you know that there are different workspaces? A base workspace, where variables from scripts go, and local workspaces that exist only when a function is being run and vanish once you leave the function.

请先登录,再进行评论。


Juliana  Corlier-Bagdasaryan
编辑:Juliana Corlier-Bagdasaryan 2017-11-6
I have a related problem of variables not appearing in the workspace, but which has nothing to do with functions. If I manually create any variable (like 'test = 5'), it would not be visible in the workspace window. However, if I list variables (using 'who' or 'whos') all variables would show up. I never had this problem before, only after updating to Matlab 2017b.
I definitely think this is a bug or me misunderstanding some newly released functionality. I have tried re-installing Matlab, which helped at first. But eventually the problem returned after a few Matlab sessions (Not sure if this is somehow related to the debug mode?).
Any ideas welcome. Thanks.
  6 个评论
Image Analyst
Image Analyst 2020-4-25
Why is no one using psr to show us screen captures? It does not good if you just same "same here" - that does not give me any information to try to help you.
FAS
FAS 2022-3-2
I have attached the recording for the screen. I am facing the same problem. The variables are not appearing in the workspace when I run the .m file.

请先登录,再进行评论。


HARMONY MNCUBE
HARMONY MNCUBE 2020-5-30
dbstop if error

Aaron
Aaron 2023-2-3
Also seems to depend on scoping, so a variable defined inside of a for loop for example, will not show up in the workspace afterwards (even though the iterator value is, assuming it hasn't been cleared).
Try defining outside of a dedicated scope like a loop or function.

类别

Help CenterFile Exchange 中查找有关 Debugging and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by