필터 지우기
필터 지우기

Saving Plots to a Folder with the Title Name

조회 수: 2 (최근 30일)
Amanda
Amanda 2013년 5월 16일
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
Matt Kindig
Matt Kindig 2013년 5월 16일
Can you still post your code?
Amanda
Amanda 2013년 5월 16일
편집: Amanda 2013년 5월 16일
Thanks David, This will work.

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

채택된 답변

David Sanchez
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')
  댓글 수: 1
Amanda
Amanda 2013년 5월 16일
That is it. Some reason the title name was giving me trouble.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by