필터 지우기
필터 지우기

.mat file with structures

조회 수: 2 (최근 30일)
Joaquim
Joaquim 2016년 10월 4일
댓글: Joaquim 2016년 10월 5일
Hello everyone! I'm trying to create a .mat file with a struct inside. Something like this:
field2='TE'; value2=TE;
field3='FieldStrength'; value3=3;
field1='images'; value1=im;
field4='PrecessionIsClockwise'; value4=1;
data=struct(field1,value1,field2,value2,field3,value3,field4,value4);
save data.mat data
where 'TE' is a vector and 'im' is a 5-D complex matrix.
Then this message appears: "Warning: Variable 'data' cannot be saved to a MAT-file whose version is older than 7.3. To save this variable, use the -v7.3 switch. Skipping...".
I have 3 datasets and this only appears for the 2nd and 3rd dataset. For the 1st everytinh is working fine. I've already tried to use the switch case but it still doesn't work. Anyone can help me?
  댓글 수: 1
Steven Lord
Steven Lord 2016년 10월 5일
What are the classes and sizes of the variables TE and im? The whos function should show both these pieces of information for these variables.

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

채택된 답변

Massimo Zanetti
Massimo Zanetti 2016년 10월 4일
Simply use the v7.3 switch like this
save('data.mat','data','-v7.3');
  댓글 수: 1
Joaquim
Joaquim 2016년 10월 5일
An if I'm using a GUI? The function uisave doesn't allow the use of more than two inputs, so I can't use the '-v7.3'.
I tried something like this:
uisave('outParams',['outParams_' PicNameWithTag],'-v7.3');
where outParams is the variable and outParams_ is the name of the saved resuls.
Thanks in advance!

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

추가 답변 (1개)

Jan
Jan 2016년 10월 5일
You can set the default format for MAT files in the preferences menu. If you store variables in the struct, which cannot be saved in older MAT formats, there is no way to do this by uisave. But look in the code of uisave.m for building your own save dialog.
  댓글 수: 1
Joaquim
Joaquim 2016년 10월 5일
Thanks! It worked perfectly!

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

카테고리

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