using .mat and .m files in GUI
18 views (last 30 days)
Show older comments
Background: I am building a GUI which uses uigetfile to allow user to select .mat file containing data of interest. The .mat file contains some matrices, from which the GUI will select one with a certain name and pass it to a function outside the GUI.
My question: How can I get the GUI to pass the matrix of interest from a .mat file that the user selects to an outside function? I began by finding the handles of the outside function by
functionhandle=@function;
[output]=functionhandle(matrix from .mat file, etc.);
Thanks
0 Comments
Answers (2)
Fangjun Jiang
on 16 Aug 2011
a=load('datafile.mat');
VarName=fieldnames(a);
will give you all the variable names in datafile.mat. Then, select a variable name and pass the value to your function.
MyVarName=VarName{1};
functionhandle(a.(MyVarName))
0 Comments
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!