Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How to Plot multicolor Vector

Asked by Wellinton on 26 Jun 2013

Hello,

I have a line code which is:

plot(Srn(:,1),'*g')

the vector Srn has 178 elements. How can I plot the range 1-59 in red, 60-131 in black and 132-178 in blue?

Thanks

0 Comments

Wellinton

Products

No products are associated with this question.

1 Answer

Answer by the cyclist on 26 Jun 2013

Here's one way:

figure
hold on
plot(Srn(1:59,1),'*r')
plot(Srn(60:131,1),'*k')
plot(Srn(132:178,1),'*b')

2 Comments

Wellinton on 27 Jun 2013

thanks

the cyclist on 27 Jun 2013

If you found that my answer solved your question, you may want to officially accept it, which will help people looking for similar solutions in the future.

the cyclist

Contact us