Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

plotting the output of a for loop in a single color

1 Ansicht (letzte 30 Tage)
Michael Gibson
Michael Gibson am 12 Nov. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
So I have a series of x-intercepts that I need to turn into a plottable piecewise defined for sin(x) function, which I have been able to do with the following code:
years = [1350,1342,1302,1284,1204,1184,1144,1126,1096,1056,1036];
target = 1350 - years;
for i=2:11
x_for = [target(i-1):0.1:target(i)];
inc = target(i)-target(i-1);
a = target(i-1);
b = target(i);
F = ((-1)^(i-1))*(inc)*sin((x_for-target(i-1))/inc*pi());
plot(x_for,F)
hold on
end
hold off
The problem is that the plot changes color every time it crosses the x-axis. Is there some way that I can get the plot to be all one color?

Antworten (1)

Armin Mashhadi
Armin Mashhadi am 12 Nov. 2019
I don't know did i got the point or not,
But check does it work?
replace line 9 with this:
plot(x_for,F,'b')
  1 Kommentar
Michael Gibson
Michael Gibson am 12 Nov. 2019
Yup, that worked! I'm kinda sad that I didn't think of that myself...
Thanks!

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by