![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1751299/image.png)
MATLAB not saving variables to workspace
53 views (last 30 days)
Show older comments
Elvin
on 7 Jan 2014
Moved: Walter Roberson
on 12 Aug 2024 at 20:56
I don't know what's wrong with my MATLAB. Every time I run the dummy.m using the F5 in the editor, all the variables are being displayed in the workspace. But when I run the NitrogenDef.m using again the F5 in the editor, all the variables used in the NitrogenDef.m are not displayed in the workspace. Any help with this? Thanks!
1 Comment
abdelkader omr
on 12 Aug 2024 at 19:18
Moved: Walter Roberson
on 12 Aug 2024 at 20:56
I saved figure as follow,but I can't find it in my workspace
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1751299/image.png)
Accepted Answer
Ryan Johnson
on 7 Jan 2014
That's because NitrogenDef is a function, so any variables created within it are only scoped for the life of the function (unless made global).
Comment out the first line function NitrogenDef() and it will run as a script.
7 Comments
More Answers (1)
Azzi Abdelmalek
on 7 Jan 2014
They are different type of file : script file and function file
0 Comments
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!