Effacer les filtres
Effacer les filtres

File running through GUI not using values from the workspace

1 vue (au cours des 30 derniers jours)
Henry
Henry le 2 Juil 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

Réponses (1)

Jan
Jan le 4 Juil 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 commentaires
Image Analyst
Image Analyst le 5 Juil 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 le 5 Juil 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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by