How to load a variable from workspace into the code of GUI?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have developed a GUI.There I have placed an edit box and a push button.After writing a variable name from workspace with .mat extension in edit box, I click on push button whose first line in GUI code is N=get(handles.edit1,'string') hence "N" contains the name of that variable.The next line in the code is load N to load the variable for operations.But this generates error and command window says Unable to read file 'N': no such file or directory. Please suggest me a way to come out of this situation.
0 commentaires
Réponses (1)
Image Analyst
le 30 Juin 2013
N does not contain the name of any variable. N contains the string in your edit box called edit1. If, for some reason, you had your user type the file name of a mat file into that edit box instead of using uigetfile(), then you would do
storedStructure = load(N);
Now, the variable "storedStructure" (which is a structure) will contain all the variables that you saved into the mat file (when you called the save() function) as members ("fields") of that structure variable.
If the string in your edit box is the name of a variable instead of the name of a file, (it's hard to tell exactly from your description), then you'd have to know the name of the mat file somehow and use dynamic structure names to recall it. But this would be an unusual use of save() and load(), as almost always you know in advance what you want to save or recall from the mat file.
2 commentaires
Image Analyst
le 1 Juil 2013
I didn't say that. I said that N contains whatever is IN edit1, not "edit1" itself. For example if you had abc in edit1, then N would be 'abc'. And typing whos N on the command line would show:
Name Size Bytes Class Attributes
N 1x3 6 char
It would not show 'abc.mat'. There is something you're not sharing with us.
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!