using .mat and .m files in GUI

15 Ansichten (letzte 30 Tage)
miner
miner am 16 Aug. 2011
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

Antworten (2)

Walter Roberson
Walter Roberson am 16 Aug. 2011

Fangjun Jiang
Fangjun Jiang am 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))

Kategorien

Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by