フィルターのクリア

File running through GUI not using values from the workspace

1 回表示 (過去 30 日間)
Henry
Henry 2013 年 7 月 2 日
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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by