solve function of ode45

조회 수: 1 (최근 30일)
Mustafa Alhandhali
Mustafa Alhandhali 2019년 4월 8일
답변: madhan ravi 2019년 4월 9일
function dzdt= speed(x,z)
M=10; m=0.1; c=0.2; k=0.4; F=10*x ;
dzdt(1)=z(2);
dzdt(2)=-(c*z(1) - F + k*z)/(M + m);
dzdt=dzdt';
end
i want to use this function to plot y versus x versus

답변 (2개)

Star Strider
Star Strider 2019년 4월 8일
There is an error in the code you posted. I believe it should be:
dzdt(2,:)=-(c*z(1) - F + k*z(2))/(M + m);
Otherwise, this is a straightforward application of ode45 (link). See the function documentation for details.

madhan ravi
madhan ravi 2019년 4월 9일
Try this:
There is nothing wrong with your code:
dzdt(2)=-(c*z(1) - F + k*z(2))/(M + m);
% ^^^---missed it

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by