Saving multiple figures to a named folder

Hi there
I am running a function using several macros for example
function fftval(in,out)
x = load(in); % or importdata or csvread or xlsread or whatever your reading function is.
y = fft(x);
figure(1)
plot(y)
save(out,'y')
file 2: called "processall"
in = {'file1.mat','file2.mat'};
out = {'w1','w2'};
for i = 1:numel(in)
fftval(in{i},out{i})
end
However I want to also save my figures to a folder called fftplots that is on my desktop. How can I do this?

댓글 수: 2

Naishil shah
Naishil shah 2014년 3월 4일
Try this,
baseFileName = sprintf('figure_%d.jpg',k); % Specify some particular, specific folder: fullFileName = fullfile('D:\myPlots', baseFileName); figure(k); % Activate the figure again. export_fig(fullFileName); % Using export_fig instead of saveas.
Naishil shah
Naishil shah 2014년 3월 4일
basePath = 'YOUR/PATH/%d.jpeg' for k = 1:length(jpegFiles)
path = sprintf(basePath,k) imwrite..

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

답변 (1개)

Srinivas
Srinivas 2014년 3월 4일
편집: Srinivas 2014년 3월 4일

0 개 추천

function fftval(in,out)
x = load(in); % or importdata or csvread or xlsread or whatever your reading function is.
y = fft(x);
figure(1)
plot(y)
save(out,'y')
saveas(gcf, 'figureName.jpg')
something like this

댓글 수: 2

Bran
Bran 2014년 3월 4일
Thank you so much but how would you go about naming them something different each time like if I put in an extra line out2 with all the names how could I then put that into my main function?
I am not sure if understood you correctly, but you can save them based on your input file name
append '.jpg' to your input file name before you save the figure,
figureName = [ in '.jpg'] %%if you have an extension in your input file make sure to remove it.
saveas(gcf, figureName)

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

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

2014년 3월 4일

댓글:

2014년 3월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by