필터 지우기
필터 지우기

How to get a specific field from a structure stored in .mat file?

조회 수: 71 (최근 30일)
Sidra Aleem
Sidra Aleem 2017년 5월 8일
댓글: Tobias Adam 2022년 4월 28일
I have saved my structure in . mat using.
filename = 'D:\我的文档\MATLAB\efe\Database.mat';
save(filename,'Data');
Structure got saved . However when I try to load a specific field then I cannot. I used the following line of code for loading.
S = load(filename,'Data.Images');
But when I click S in work space its empty and I got warning " Warning: Variable 'Data.Images' not found. " I also tried using -struct in save command but it throws error.
The argument to -STRUCT must be the name of a scalar structure variable.
Though It has been saved in .mat file. Below is attached screen shot of.mat file.Kindly guide me how to load Images field from stored structure in .mat file
  댓글 수: 1
Adam
Adam 2017년 5월 8일
편집: Adam 2017년 5월 8일
As far as I am aware you cannot load independent fields of a struct. If you save them as separate variables in the .mat file rather than a struct then you can do this, or you can load the whole struct, extract the field and get rid of the rest of the struct if it is too big.

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

답변 (2개)

Walter Roberson
Walter Roberson 2017년 5월 10일
It is not possible to load an individual field from a struct array in MATLAB.
  댓글 수: 1
Tobias Adam
Tobias Adam 2022년 4월 28일
Thank you very much for the answer :-)
Will it be possible in any moment?

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


KL
KL 2017년 5월 8일
  댓글 수: 1
Sidra Aleem
Sidra Aleem 2017년 5월 9일
@KL i have visited this link before posting my own question. And I have stated the errors that I am facing by using the solutions in the link you mentioned.

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

카테고리

Help CenterFile Exchange에서 结构体에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!