MATLAB not saving variables to workspace

47 Ansichten (letzte 30 Tage)
Elvin
Elvin am 7 Jan. 2014
Verschoben: Walter Roberson am 12 Aug. 2024
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 Kommentar
abdelkader omr
abdelkader omr am 12 Aug. 2024
Verschoben: Walter Roberson am 12 Aug. 2024
I saved figure as follow,but I can't find it in my workspace

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ryan Johnson
Ryan Johnson am 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 Kommentare
Elvin
Elvin am 7 Jan. 2014
It's now okay. I just cut the Blobs function and paste it to a new editor and save it sa Blobs.m. And on the NitrogenDef, I already commented the first line.
Thank you very much for the help :)
To Minh Tan Le
To Minh Tan Le am 20 Jan. 2017
Thanks Ryan.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 7 Jan. 2014
They are different type of file : script file and function file

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by