Truble with LOAD in GUI

4 vues (au cours des 30 derniers jours)
Jiri Franc
Jiri Franc le 18 Déc 2014
Commenté : Jiri Franc le 18 Déc 2014
Hi, I have problem with loading variables to worksapace using GUI. What I want to do is that when I press the button, open dialog pops up and I select *.mat file, which I created earlier. To this point everything works fine. Name of the file is assigned to a variable. After that I do not realy know what to do. I know, that I simply cannot use load(variable). But even if I tried some modification with assignin and evalin, I sitll can get those variables stored in *.mat file to workspace.
Here is the CallBack function:
function open_menubutton_callback(u,t)
file = uigetfile('*.mat')
load(file,'*.mat')
Any sugestions, what should I add or change?

Réponse acceptée

Orion
Orion le 18 Déc 2014
Hi,
one suggestion :
[FileName,PathName] = uigetfile('*.mat');
evalin('base',sprintf('load(''%s'')',fullfile(PathName,FileName)))
  1 commentaire
Jiri Franc
Jiri Franc le 18 Déc 2014
Works perfectly! Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT Files 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!

Translated by