Reputation: 975
In MATLAB, I'm trying to plot a series of plots in a loop with the following data:
x1 = [ 1 2 3 4 5]
y1 = [ 1 1 1 1 1]
x2 = [ 1 2 3 4 5]
y2 = [ 2 2 2 2 2]
x3 = [ 1 2 3 4 5]
y3 = [ 2 2 2 2 2]
plot(x,y)
title('First Plot')
THEN suppress the output and save all plots to a folder,
with the each file displaying the title names:
First Plot
Second Plot
Third Plot
Upvotes: 0
Views: 2496
Reputation: 483
For Saving the plot to a file, with the title name, you can use the following
graphTitle='first plot';
hold on
h=figure(1);
title('first plot');
hold off
fileName=strcat('path to save',graphTitle,'.jpg');
print(h,'-djpeg',fileName);
If you need to create and save a lot of files, create a vector of file names, of the same size as the number of vectors (or dimension of the matrix) you need to plot. In a look create a handle using the index of the current file Name and do the above, you should be able to print the with the title you need etc.
When you use the above code, all the plots are visible on the screen and then printed to the file.
Upvotes: 1