ODE45 for a system of diff eq with a vector eq
이전 댓글 표시
Hi,
I am trying to solve a 2 equations system of ODE where the first function is a 2x1 vector and the second a scalar. I tried a simple example but I get an error such as: "in an assignment A(I)=B, the number of elements in B and I must be the same"
also before I got an error claiming that the outcome of @rigid is a 2x1 and my input as initial conditions is a 3x1 and thus is wrong. So this means that matlab is not recognizing that my outcome y should be a 3x1. I dont know how to fix this.
My code is:
function dy = rigid(t,y);
rho1=zeros(2,1)) rho1(1,1)=0.5; rho1(2,1)=2; rho0=1; mu1=zeros(2,2); mu1(1,1)=2.2; mu1(1,2)=1.2; mu1(2,1)=0.4; mu1(2,2)=2; mu0=zeros(2,1); mu0(1,1)=1.2; mu0(2,1)=3.2;
dy=zeros(3,1);
dy(1)=rho1-mu1*y(1:2); dy(2)=rho0-mu0'*y(1:2);
[t,y] = ode45(@rigid,[0 12],[0 0 0]);
Any help with this?
thanks in advance.
채택된 답변
추가 답변 (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!