Filter löschen
Filter löschen

File running through GUI not using values from the workspace

1 Ansicht (letzte 30 Tage)
Henry
Henry am 2 Jul. 2013
I've got a GUI which runs a file using some values the user has inputed into the GUI. It also uses some variables from the workspace, as defined by a different file.
However, when i try to run this file from the GUI, it tells me that certain variables haven't been defined, dispite them being in the workspace.
It runs fine as per normal, but when I run it from the GUI it seems as though it stops looking at the workspace?
Is this the case? And how do I fix this?
Thanks,
Henry

Antworten (1)

Jan
Jan am 4 Jul. 2013
Which "workspace" do you mean? Each function has its own workspace. Is the "file" you run a script or a function? Where are the variables defined in the GUI? If they are created in a callback function, they exist in this callback's workspace as long as it runs only.
  3 Kommentare
Image Analyst
Image Analyst am 5 Jul. 2013
What Jan said is still true. Your second "gui" still won't see the variables. Anyway you said they were already there in the base workspace in your original message, which means that you must have run gui#1 first already so I don't see that your fix did anything different. The only way for your gui#2 to see the variables in the base workspace or gui#1's workspace is to use things like global, setappdata/getappdata, assignin(), etc. See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
Henry
Henry am 5 Jul. 2013
Sorry, i didn't make myself very clear in the last comment.
the callback runs an .m file which in turn runs another .m file. All the other initial values which my user can't edit are defined in the first .m file and then plugged into the calculations in the second .m file

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by