How do I save multiple variables from the workspace with a the name that the user gave them in through an input?

조회 수: 48 (최근 30일)
I am developing a program in which at a certain point the user must be able to name the file where those variables are saved prior to saving them,i.e. , the input receives the name and saves the file with that name that was given prior.
Thanks in advance!
Best regards

채택된 답변

Matt J
Matt J 2014년 11월 29일
As an example
a=1;
b=2;
filename='SomeVars';
save(filename,'a','b')
  댓글 수: 10
João
João 2014년 11월 29일
startingFolder = userpath
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
return;
end
fullFileName = fullfile(folder, baseFileName)
fid = fopen('data.out', 'at');
if fid ~= -1
fprintf(fid, '\n');
fclose(fid);
end
Matt J
Matt J 2014년 11월 29일
I don't see any call to dlmwrite in there. You also need to post the errors you received, for us to guess why they occur.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by