Matlab 將一個矩陣儲存在.mat檔案中,或讀取.mat檔案
阿新 • • 發佈:2019-02-01
例13-3 open與load的比較。
>> clear
>> A = magic(3);
>> B = rand(3);
>> save
Saving to: matlab.mat
>> clear
>> load('matlab.mat')
>> A
A =
8 1 6
3 5 7
4 9 2
>> B
B =
0.9501 0.4860 0.4565
0.2311 0.8913 0.0185
0.6068 0.7621 0.8214
>> clear
>> open('matlab.mat')
ans =
A: [3x3 double]
B: [3x3 double]
>> struc1=ans;
>> struc1.A
ans =
8 1 6
3 5 7
4 9 2
>> struc1.B
ans =
0.9501 0.4860 0.4565
0.2311 0.8913 0.0185
0.6068 0.7621 0.8214
>> clear
>> A = magic(3);
>> B = rand(3);
>> save
Saving to: matlab.mat
>> clear
>> load('matlab.mat')
>> A
A =
8 1 6
3 5 7
4 9 2
>> B
B =
0.9501 0.4860 0.4565
0.2311 0.8913 0.0185
0.6068 0.7621 0.8214
>> clear
>> open('matlab.mat')
ans =
A: [3x3 double]
B: [3x3 double]
>> struc1=ans;
>> struc1.A
ans =
8 1 6
3 5 7
4 9 2
>> struc1.B
ans =
0.9501 0.4860 0.4565
0.2311 0.8913 0.0185
0.6068 0.7621 0.8214