필터 지우기
필터 지우기

How do I plot component curves for system of differential equations? I keep getting errors for this compartment model

조회 수: 4 (최근 30일)
F=@(t,x) [-4*x(1)+4*x(2); x(1)-6*x(2)+3*x(3)+2; x(1)+2*x(2)-8*x(3)+5];
[t,x]=ode45(F,[0 3], [0 10]);
plot(t, x(:,1), t, x(:,2), t, x(:,3))

채택된 답변

Star Strider
Star Strider 2018년 6월 7일
You have to supply the same number of initial conditions to the ODE solver as you have variables in your ODE equation. Assuming you only want ‘x(3)’ to have anything in it at the start, this works:
[t,x]=ode45(F,[0 3], [0 0 10]);
The rest of your code is unchanged, although you might want to add this after your plot call:
legend('C_1(t)', 'C_2(t)', 'C_3(t)', 'Location','NE')
  댓글 수: 5
Alex Vasin
Alex Vasin 2018년 6월 7일
편집: Alex Vasin 2018년 6월 7일
Thanks for the help. I finished fixing everything to be the way I want it.

댓글을 달려면 로그인하십시오.

추가 답변 (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