matlab中save用法
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/22 13:00:52
matlab中save用法
matlab中save用法
matlab中save用法
用doc save就能得到save的用法说明
其他的函数也是
Save all variables from the workspace in binary MAT-file test.mat. Remove the variables from the workspace, and retrieve the data with the load function.
save test.mat
clear
load test.mat
Create a variable savefile that stores the name of a file, pqfile.mat. Save two variables to the file.
savefile = 'pqfile.mat';
p = rand(1, 10);
q = ones(10);
save(savefile, 'p', 'q')
Save data to an ASCII file, and view the contents of the file with the type function:
p = rand(1, 10);
q = ones(10);
save('pqfile.txt', 'p', 'q', '-ASCII')
type pqfile.txt
Alternatively, use command syntax for the save operation:
save pqfile.txt p q -ASCII
Save the fields of structure s1 as individual variables. Check the contents of the file with the whos function. Clear the workspace and load the contents of a single field.
s1.a = 12.7;
s1.b = {'abc', [4 5; 6 7]};
s1.c = 'Hello!';
save('newstruct.mat', '-struct', 's1');
disp('Contents of newstruct.mat:')
whos('-file', 'newstruct.mat')
clear('s1')
load('newstruct.mat', 'b')