Saving Plots to a Folder with the Title Name
3 次查看(过去 30 天)
显示 更早的评论
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
Thanks,
Amanda
4 个评论
采纳的回答
David Sanchez
2013-5-16
name = 'my_name';
for k = 1:3
name_2 = strcat(name,num2str(k));
h=figure;
plot(x(k),y(k)); % your data there
my_title = strcat('title_',num2str(k));
title(my_title)
saveas(h,name,'jpg')
end
If you do not need to see the plot, you can hide it:
h=figure('visible','off')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!