Issues with other scripts accessing workspace variables

4 Ansichten (letzte 30 Tage)
Cami
Cami am 24 Mär. 2025
Bearbeitet: Stephen23 am 25 Mär. 2025
Hello,
I have pre-defined a set of variables in one .m file and written a function in another file that needs to use some of these variables. I ran the variables file, can see the variables stored in the workspace, and yet when I try to run the functions they do not recognize the variables. Any ideas?
I have attached a picture. It shows the variables storing file, the workspace with said stored variables, and an error that appears in the command window when the functions try to call the workspace variables.
Thank you.
  1 Kommentar
Stephen23
Stephen23 am 25 Mär. 2025
Bearbeitet: Stephen23 am 25 Mär. 2025
Calling CLEAR ALL is an example of:
Do not write CLEAR ALL at the top of everything that you write. It will not help you.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

dpb
dpb am 24 Mär. 2025
<function>s have an independent workspace from the base workspace. See <Base and Function Workspace> and the reference linked to there that shows best practice is to pass arguments to your functions.

Kategorien

Mehr zu Workspace Variables and MAT Files 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