How do I use the functional form of the LOAD and SAVE commands?

1 view (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 10 Dec 2021
Edited: MathWorks Support Team on 13 Dec 2021
The documentation and help entries for the SAVE function:
This describes the basic syntax for this command. You can also type the following at the MATLAB command prompt:
help save
for extensive syntax explanation.
Here is an additional example:
var1 = [10 20 30];
var2 = 'var2';
save('fname','var1','var2')
var3 = 100;
save('fname','var3','-append')
The syntax is the same for the LOAD command. For example, the following code will SAVE each column of a variable 'a' to different ascii files:
a = rand(6); %make a
filename = ['a1.txt';'a2.txt';'a3.txt';'a4.txt';'a5.txt';'a6.txt';]; %list your file names
for i = 1:length(a)
temp = a(:,i);
save(filename(i,:),'temp','-ascii'); %save to the specified file
end

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!