How to define different color for all three plots?

1 view (last 30 days)
omega = 1; alpha = 1;beta=1;
f=@(ts,theta)[omega + alpha*(sin((theta(2)-theta(1))));
omega + alpha*(sin(theta(1)-theta(2)))+beta*(sin(theta(3)-theta(2)));
omega + beta*(sin((theta(2)-theta(3))))];
range = [0,1];
thetainit = [0.1,0.3,0.2];
[range,theta] = ode45(f,range,thetainit);
plot(range,theta,'Linewidth', 2)
xlabel('Range');
ylabel('Theta');
legend('Theta1','Theta2','Theta3');

Accepted Answer

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH on 10 Nov 2019
solution:
omega = 1; alpha = 1;beta=1;
f=@(ts,theta)[omega + alpha*(sin((theta(2)-theta(1))));
omega + alpha*(sin(theta(1)-theta(2)))+beta*(sin(theta(3)-theta(2)));
omega + beta*(sin((theta(2)-theta(3))))];
range = [0,1];
thetainit = [0.1,0.3,0.2];
[range,theta] = ode45(f,range,thetainit);
h=plot(range,theta,'Linewidth', 2);
set(h,{'Color'},{'r'; 'g'; 'b'})
xlabel('Range');
ylabel('Theta');
legend('Theta1','Theta2','Theta3');

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!