Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Proble Saving a Binary File

조회 수: 2 (최근 30일)
Shani Gal
Shani Gal 2012년 6월 29일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi
I am trying to save my matlab variables in binary files, unsuccessfully.
For example, if I have
A=[1,1,1;2,2,2] and I save it as ascii file:
save('test_file.txt','A','-ASCII')
I have no problem loading and reading it:
A=load('test_file.txt','A','-ASCII') And getting A back
A =
1 1 1
2 2 2
And accessing part of it ( for example B=A(1,1))
But if I try to save it as binary or matlab format
save('test_file.mat','A')
when I load it, I get
A=load('test_file.mat','A')
A =
A: [2x3 double]
And I can’t access the values in it.
Why?
Thanks
Shani

답변 (1개)

Walter Roberson
Walter Roberson 2012년 6월 29일
When you assign the output of load() of a .mat file, the result is a structure variable with fields that are the name of the variables that were loaded. You loaded variable 'A' so there will be a field named 'A' in the variable you assigned the output to, which happens to be 'A', so your actual data will be in A.A

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by