using .mat and .m files in GUI

조회 수: 19 (최근 30일)
miner
miner 2011년 8월 16일
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

답변 (2개)

Walter Roberson
Walter Roberson 2011년 8월 16일

Fangjun Jiang
Fangjun Jiang 2011년 8월 16일
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))

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by