필터 지우기
필터 지우기

Saving variables and figures uniquely when processing a sequence of files

조회 수: 1 (최근 30일)
I am trying to save a variable (A) with the num2str(k)so that I can run multiple files at once, but keep getting an error.
example: hgsave('SummaryPlot' num2str(ii)); and hgsave('SummaryPlot' num2str(ii),'.txt');
If there a better way to do this?

채택된 답변

Kye Taylor
Kye Taylor 2013년 2월 15일
편집: Kye Taylor 2013년 2월 15일
try
hgsave(['SummaryPlot',num2str(ii)]);
notice the square brackets in order to concatenate 'SummaryPlot' and the output from num2str(ii). Same with
hgsave(['SummaryPlot',num2str(ii),'.txt']);

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 2월 15일
편집: Image Analyst 2013년 2월 15일
If you're familiar with C, you'll probably prefer the sprintf() way:
baseFileName = sprintf('Summary Plot %d.txt' ii);
fullFileName = fullfile(yourFolder, baseFileName);
hgsave(fullFileName);
yourFolder could be "pwd" - the current folder - if you wish. Also, please consider export_fig instead of hgsave: http://www.mathworks.com/matlabcentral/fileexchange/index?sort=downloads_desc&term=

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by