How to save the plot with two lines

조회 수: 5 (최근 30일)
Nirmal
Nirmal 2012년 7월 13일
x=rand(1,10);
y=1:10;
h=plot(x,y,'r',x,y,'g');
saveas(h, 'test','jpg');
I want to save the plot above but i get an error
??? Operands to the || and && operators must be
convertible to logical scalar values.
Error in ==> saveas at 64
while ~isempty(h) && ~isfigure(h)
I know its because h has two values, I just dont know how to save both of these in the same image file.

채택된 답변

Albert Yam
Albert Yam 2012년 7월 13일
The 'plot' is the line, what you want to save is the figure.
h=figure;
x=rand(1,10);
y=1:10;
plot(x,y,'r',x,y,'g');
saveas(h, 'test','jpg');
  댓글 수: 1
Nirmal
Nirmal 2012년 7월 13일
Thank you. That was quick Sir.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by