File running through GUI not using values from the workspace

2 次查看(过去 30 天)
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

回答(1 个)

Jan
Jan 2013-7-4
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 个评论
Image Analyst
Image Analyst 2013-7-5
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 2013-7-5
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by