Plotting graphs while solving Multiple Differential Equations using ODE45
이전 댓글 표시
I created two different scripts to solve a system of differential Equations, while the code worked perfectly fine and graphs were as I expected, I wasn't able to concatenate the various graphs through the "hold on". Please help me locate the error or I would love a new improved version of this code.
The two scripts are:
***********************************************************************************
****Script 1
function fval=rotationeqn(t,y)
A11=y(1);
A12=y(2);
A22=y(3);
recilamda=1000;
Wi=0;
fval(1,1)=-1*recilamda*(A11-1)+Wi*recilamda*A12;
fval(2,1)=-1*recilamda*A12+Wi*0.5*recilamda*(A22-A11);
fval(3,1)=-1*recilamda*(A22-1)-Wi*recilamda*A12;
hold on
Wi=1;
fval(1,1)=-1*recilamda*(A11-1)+Wi*recilamda*A12;
fval(2,1)=-1*recilamda*A12+Wi*0.5*recilamda*(A22-A11);
fval(3,1)=-1*recilamda*(A22-1)-Wi*recilamda*A12;
hold on
end
**********************************************************************************************
*****script 2
x=pi/6;
yo=[cos(x)*cos(x);sin(x)*cos(x);sin(x)*sin(x)];
tSpan=[0:0.00001:0.01];
[tSol,ySol]=ode45(@(t,y) rotationeqn(t,y),tSpan,yo);
plot(tSol,ySol(:,2),'r');
hold on
********************************************************************************************
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!