solve function of ode45
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Star Strider
on 8 Apr 2019
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.
0 Comments
madhan ravi
on 9 Apr 2019
Try this:
There is nothing wrong with your code:
dzdt(2)=-(c*z(1) - F + k*z(2))/(M + m);
% ^^^---missed it
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!