MATLAB - plot a vector using different line style

130 Views Asked by At

I have an array where the first column is the data I want to plot and the second column contains either 1 or -1 to indicate stability. I want to plot the portions of the data marked as '1' with a dashed line, but the rest with a solid line. How do I do this without ending up with the two lines being disconnected? Is there a neat way?

1

There are 1 best solutions below

3
On

First extract to vectors, the ones associated with -1, and 1 with :

 dashed = your_Vector(find(your_Vector(:, 2) == 1))
 solid  = your_Vector(find(your_Vector(:, 2) == -1 ))

and then plot as you wish.