Save Struct as .mat file!!!

조회 수: 37 (최근 30일)
M G
M G 2013년 8월 11일
댓글: Walter Roberson 2021년 1월 14일
Hello all,
I have a problem in saving Struct format in .mat file.
If I have "a" as 1x5 struct
So, in command window it looks like this:
a =
ans =
246
ans =
444
ans =
630
ans =
810
ans =
984
Any way that I can save it as a .mat file of 1x5?
Thanks so much for your help :)
  댓글 수: 1
M G
M G 2013년 8월 11일
Here is the file:
https://dl.dropboxusercontent.com/u/19202474/matFile.zip
I want to save
a.latency
which consists of 947 value in one mat file. I do like:
save filename.mat a.latency
... but doesn't work!!!

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

채택된 답변

Jan
Jan 2013년 8월 12일
Of course this does not work, because "a.latency" is not a name of a variable. You need:
save('filename.mat', 'a')
The functional form is less confusing for the save command.
If you want to save the fields "latency" only:
latency = {a.latency};
save('filename.mat', 'latency')
  댓글 수: 11
Gustavo Araujo
Gustavo Araujo 2021년 1월 13일
Is there a way to save those mat files sequentially? I mean: create a loop saving File1.mat, File2.mat and so on. I'm trying:
for i=1:3
Ir(i) = [Ir];
end
save('Irn.mat', 'Ir');
but the Irn saves in another column the second and third variable. How to proceed correctly?
Thank you in advance.
Walter Roberson
Walter Roberson 2021년 1월 14일
for K = 1 : number_of_files
filename = sprintf('File%d.mat', K);
save(filename, 'Ir')
end

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

추가 답변 (1개)

the cyclist
the cyclist 2013년 8월 11일
What do you mean by "a .mat file of 1x5"?
>> save filename.mat a
will save the structure, exactly as it is in the workspace.
>> load filename.mat a
will load it back into the workspace.
  댓글 수: 1
M G
M G 2013년 8월 11일
https://dl.dropboxusercontent.com/u/19202474/matFile.zip
I uploaded the .mat file in here. I want to save a.latency which consists of 947 value in one mat file. I do like:
save filename.mat a.latency
but doesn't work!!

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

카테고리

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