How to plot one curve and change color according to value
The tricky thing is that I get an attribute with the values and would like to have this part in the plot in a different color:
x = linspace(0,10);
y = sin(3*x).*exp(0.5*x);
c = find(y > 25);
m(length(x)) = 0;
m(c) = 1;
figure;
plot(x, y, ‘b’)
Where m becomes 1 the color should be red, else blue.
Can someone find the easiest way to do this?The tricky thing is that I get an attribute with the values and would like to have this part in the plot in a different color:
x = linspace(0,10);
y = sin(3*x).*exp(0.5*x);
c = find(y > 25);
m(length(x)) = 0;
m(c) = 1;
figure;
plot(x, y, ‘b’)
Where m becomes 1 the color should be red, else blue.
Can someone find the easiest way to do this? The tricky thing is that I get an attribute with the values and would like to have this part in the plot in a different color:
x = linspace(0,10);
y = sin(3*x).*exp(0.5*x);
c = find(y > 25);
m(length(x)) = 0;
m(c) = 1;
figure;
plot(x, y, ‘b’)
Where m becomes 1 the color should be red, else blue.
Can someone find the easiest way to do this? plot, changing color MATLAB Answers — New Questions