Borrar filtros
Borrar filtros

GUI Question: How can I import a variable/vector/matrix into a GUI I created?

14 visualizaciones (últimos 30 días)
Hi! For example, I am creating my own GUI and I want to Import a variable or a vector from workspace or file system? How do I go about doing this? Thanks very much!

Respuesta aceptada

Luffy
Luffy el 30 de Sept. de 2012
Editada: Luffy el 30 de Sept. de 2012
If you want to access data that is in base workspace in your gui functions, use
v = evalin('base','name of variable u want to access'); % the variable's data is now stored in v. If u want to save data of ur gui work space to base, use
assignin('base','name of variable u want to save','value of variable'); Several ways are shared in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
  1 comentario
Iris
Iris el 4 de Oct. de 2012
I was able to pass my variables in between base workspace and gui and also call back functions through this. Thanks!

Iniciar sesión para comentar.

Más respuestas (2)

Matt J
Matt J el 30 de Sept. de 2012
This might be what you want
Also, you can pass MATLAB variables to the GUI as input arguments when it is initially launched:
mygui(A,B,C,...)
The variables A,B,C,... will be passed to your gui's OpeningFcn, assuming you developed the gui using GUIDE, as varargin inputs.

Image Analyst
Image Analyst el 30 de Sept. de 2012
You can import a file from the file system using uigetfile() to get its filename, then use functions such as dlmread, csvread, textscan, importdata, etc. to read in the contents of the file.

Categorías

Más información sobre Standard File Formats 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