Saving multiple figures to a named folder

1 view (last 30 days)
Bran
Bran on 4 Mar 2014
Commented: Naishil shah on 4 Mar 2014
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 Comments
Naishil shah
Naishil shah on 4 Mar 2014
basePath = 'YOUR/PATH/%d.jpeg' for k = 1:length(jpegFiles)
path = sprintf(basePath,k) imwrite..

Sign in to comment.

Answers (1)

Srinivas
Srinivas on 4 Mar 2014
Edited: Srinivas on 4 Mar 2014
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 Comments
Srinivas
Srinivas on 4 Mar 2014
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)

Sign in to comment.

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!