how to load matfile through push button click in matlab GUI
4 views (last 30 days)
Show older comments
i am using code like below
[filename pathname]=uigetfile('*.mat',-mat)
x2=load(filename,'-mat);
evalin('base',x2);
problem here is that first 2 lines w/o x2= are executing in matlab command (only first 2 lines if i evaluated w/oGUI).then it is loading mat variables into matlab workspace. when i am executing through GUI pushbutton, only file name is loading into workspce instead of variables & also error was shown at evalin. error---undefined function or method evalin for i/p arguments of type cell,
any help will be apreciated
1 Comment
Jan
on 1 Jul 2014
I've formatted your code. Please care about a proper formatting - thanks.
The posted code has no valid Matlab syntax. Therefore we cannot guess its intention. What do you want to achieve by the "-mat" argument of uigetfile()?
Answers (1)
Jan
on 1 Jul 2014
Please read the documentation of evalin:
doc evalin
I assume you want this instead:
assignin('base', 'x2', x2);
2 Comments
Jan
on 6 Jul 2014
@raj: Sorry, I cannot follow your descriptions. Perhaps you want the indirect and error prone method:
evalin('base', sprintf('load(%s, ''-mat'')', filename));
See Also
Categories
Find more on Workspace Variables and MAT-Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!