Matlab - Plot a Vector Using Different Line Style
$\Begingroup$ 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...
$\begingroup$
$\endgroup$
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 Answer
$\begingroup$
$\endgroup$
3
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.