struct and getfield variable value
Afficher commentaires plus anciens
Hi, I'm trying to get the value that's in the variable but I can only get to the name of the variable and not the actual value. Thank you
w = getfield(evalin('base','whos'),{13,1},'name')
w = Variable
Réponses (2)
Image Analyst
le 5 Juin 2013
0 votes
What workspace are you trying to import this variable (that lives in the base workspace) into? The workspace of one of your functions? How did a variable get into the base workspace anyway? Did you run a script and it left the variable in the base workspace, and now you're running a function, which has its own local workspace, and now you want to import the variable that your script left in the base workspace into the workspace of your function? If what I said totally confused you then you need to read up on workspaces. Also, look at the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
1 commentaire
Jan
le 5 Juin 2013
Trying to transport variables magically remote controlled is obviously a bad idea. Although it might work, I recommend not to do this:
w = getfield(evalin('base','whos'), {13,1}, 'name')
value = evalin('base', w)
Brrr. You would suffer.
2 commentaires
Vincent I
le 6 Juin 2013
Daniel Shub
le 6 Juin 2013
Did you miss the part where Jan said I recommend not to do this
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!