How to save the plot with two lines

Asked by Nirmal on 13 Jul 2012
Latest activity Commented on by Nirmal on 13 Jul 2012
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.

0 Comments

Nirmal

Tags

Products

No products are associated with this question.

1 Answer

Answer by Albert Yam on 13 Jul 2012
Accepted answer

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 Comment

Nirmal on 13 Jul 2012

Thank you. That was quick Sir.

Albert Yam

Contact us