Borrar filtros
Borrar filtros

How to access to variables saved in Matlab folder from the GUI

1 visualización (últimos 30 días)
I want to load my dataset or access any other variables that are saved to my matlab folder or are in my workspace currently from the matlab GUI I created. But when I call my functions on callback function of a button, I can't do it. Could you give me a simple example how to do it?
  2 comentarios
per isakson
per isakson el 5 de En. de 2015
"any other variables that are saved to my matlab folder" &nbsp do you mean saved in a mat-file in the current folder?
See evalin
Ege
Ege el 5 de En. de 2015
Yes exactly. I mean mat files

Iniciar sesión para comentar.

Respuesta aceptada

per isakson
per isakson el 5 de En. de 2015
Editada: per isakson el 5 de En. de 2015
Add lines similar to the following, which are copied from the doc on load
filename = 'durer.mat';
myVars = {'X','caption'};
S = load(filename,myVars{:})
to the callback function.
&nbsp
" or are in my workspace" &nbsp see evalin, Execute MATLAB expression in specified workspace and add
my_variable = evalin( 'base', 'my_variable' )
to the callback function.
  8 comentarios
Ege
Ege el 6 de En. de 2015
Making the variables global and adding assigning solved my problem thank you very much for your help :)
per isakson
per isakson el 6 de En. de 2015
Editada: per isakson el 6 de En. de 2015
"I can't do anything on it"
  • I assume that assignin actually assigned a variable in the base workspace
  • load assigns a value to the variable S.&nbsp dataset2 is not a variable, but a field of the struct S. Try churn = S.dataset2.churn;.
Comments

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Workspace Variables and MAT-Files 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