How to define different color for all three plots?

조회 수: 1 (최근 30일)
Shauvik Das
Shauvik Das 2019년 11월 10일
댓글: Shauvik Das 2019년 11월 10일
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');

채택된 답변

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019년 11월 10일
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');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by