How can I plot an array of data with different color?

I have a vector of numbers representing my data. Some of them are stable and some are not (based on my previous computations). Now how can I plot them on a same figure with different colours or symbols. I need a continuous curve. The stability information of each point is saved at another vector (consists of 0 for stable and 1 for unstable points). Number of data is high and the stability pattern is random.

Answers (1)

x=0:0.01:20;
y=sin(x);
info=randi([0 1],numel(y),1);
y1=y;
y2=y;
y1(info==0)=nan
y2(info==1)=nan
plot(x,y1,'r')
hold on
plot(x,y2,'g')

Categories

Asked:

on 29 Aug 2013

Community Treasure Hunt

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

Start Hunting!