Extracting values from fields in app designer

조회 수: 4 (최근 30일)
Alexandra Philip
Alexandra Philip 2020년 7월 13일
댓글: Sourabh Kondapaka 2020년 8월 14일
I am trying to figue out how to obtain the values from certain fields within my struct in app desginer.
I would like to pull the struct from a .mat file.
I first am using:
properties (Access = private)
Mystruct % Description
end
properties (Access = public)
end
methods (Access = private)
function Start(app)
Mystruct=load('AccelQuery.mat')
end
end
Then I should be able to use app.Mystruct in my callback function to load the struct. Any suggestions on obtaining the values from certain fields such as SERIAL_NUMBER?
  댓글 수: 6
J. Alex Lee
J. Alex Lee 2020년 8월 13일
If a .mat file is meant to contain a single structure variable, but "save"d without using the "-struct" option, you'll have to access the struct by invoking the name of the original structure's variable. So if I have
S.a = 1
S.b = 2
S.c = 3
save("testdata.mat","S")
To access the fields a, b, c from loaded data, I need to do
loadedS = load("testdata.mat")
loadedS.S.a
If you want to be able to do
loadedS.a
then you have to save as
save("testdata.mat","-struct","S")
Maybe that's what Sourabh is going to check...
Sourabh Kondapaka
Sourabh Kondapaka 2020년 8월 14일
Hi,
@J.Alex Lee is right in suggesting what I was going to check.
If his comment still does not solve the issue, please upload the 'AccelQuery.mat' for me to cross check.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by