Extracting values from fields in app designer

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 件のコメント

Alexandra Philip
Alexandra Philip 2020 年 7 月 13 日
So far I have tried,
rmdData=load('AccelQuery.mat','SERIAL_NUMBER');
SERIAL_NUMBER=rmdData.('SERIAL_NUMBER').data
Then I receive this error message:
Reference to non-existent field 'SERIAL_NUMBER'.
Any resolutions?
jonas
jonas 2020 年 7 月 13 日
Cant you just load the data when you define the public property? Otherwise you need to load the data into app.Mystruct
Alexandra Philip
Alexandra Philip 2020 年 7 月 13 日
Yes, I loaded the data when I loaded the public property. I just found that I could also load the data into my callback function in an effort to load the field from the structure and create a variable with the values from that field.
Sourabh Kondapaka
Sourabh Kondapaka 2020 年 8 月 13 日
編集済み: Sourabh Kondapaka 2020 年 8 月 13 日
Hi,
Could you please upload the 'AccelQuery.mat' file for me to cross check.
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 件)

カテゴリ

ヘルプ センター および File ExchangeCreate Custom UI Components についてさらに検索

質問済み:

2020 年 7 月 13 日

コメント済み:

2020 年 8 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by