GUI variables not going to workspace

1 visualización (últimos 30 días)
William
William el 8 de Sept. de 2011
Comentada: Ana Gonçalves el 5 de Jun. de 2020
Hello,
When running a GUI program I cannot get the variables used in the GUI to show up on my workspace. Is there a reson for this?

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 8 de Sept. de 2011
Those variables are in their own workspace. Use assignin to get them to the base if you need them there:
doc assignin
or less dangerously you could set them to application data using setappdata and then have a function that you call from the command line that retrieves them from application data ( getappdata) so that you lower the risk of overwriting important other variables.
doc setappdata
doc getappdata
  1 comentario
Ana Gonçalves
Ana Gonçalves el 5 de Jun. de 2020
Using the function assignin:
The 1st parameter (par1) is the workspace where you want to load this variable. Normally 'base' to the base workspace.
The 2nd parameter (par2) is the name you want to give to this variable in the workspace.
The 3rd, is the variable in your original name (which already contain some value inside).
I hope this help you!
assignin('par1','par2',variable);

Iniciar sesión para comentar.

Más respuestas (2)

Jan
Jan el 8 de Sept. de 2011
Yes, there is a very good reason: If you open mutliple instances of your GUI and some other GUIs in addition, your base workspace would be poluted by a lot of variables and it would be rather impossible to debug, who is responsible for the current values.
It is much safer and cleaner to keep all variables in a well defined location apart from the global workspace.

William
William el 8 de Sept. de 2011
In this GUI I am bringing in a large .mat file with a number of variables and exporting a chosen few of them to .csv files The files wouldn't convert over because it could not find the actual files. It worked a month ago but when I revisited it today it bombed.

Categorías

Más información sobre Instrument Control Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by