How to solve this ODE? Urgent help!!
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Shubham Maurya
am 26 Jul. 2014
Beantwortet: Star Strider
am 26 Jul. 2014
Please explain step wise and also I want a plot of m vs. t t varies from [0,0.5] and m(0)=0.4
Thanks
0 Kommentare
Akzeptierte Antwort
Star Strider
am 26 Jul. 2014
This is similar to your previous code, this time with the additional constant (that does not seem to affect the result). There is not much to describe, really. See the documentation on Anonymous Functions and ode45 for those details.
Otherwise:
mdot = @(t,m) -0.31458*sqrt(2E+5.*((1+(0.4-m)./0.5).^-1.4 - 1)); % Anonymous function encoding ODE
[t,m] = ode45(mdot, [0 0.5], 0.4); % Integrate using ode45
figure(1)
plot(t, m, '-*b') % Plot
grid
The ode45 call has as its arguments, the function to integrate ( mdot here ), the time span ( [0 0.5] here ), and the initial conditions ( 0.4 here, and only one because there is only one variable to integrate ). The figure plots m as a function of t plotting m(t) with a blue asterisk and drawing a blue line between them. The grid call adds grid lines to the plot.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!