how to Solve differential equation
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
jone
am 26 Jul. 2016
Kommentiert: Star Strider
am 24 Jun. 2017
Hi all
I have equation like this
dy/dt = a*y^2 + b*y + c
where a, b and c are constant
how can I solve this equation using matlab
0 Kommentare
Akzeptierte Antwort
Star Strider
am 26 Jul. 2016
I would use ode45 (unless your constants vary significantly in magnitude, then use ode15s).
The code:
a = 0.1; % Create Data
b = 0.2; % Create Data
c = 0.3; % Create Data
f = @(t,y) a.*y.^2 + b.*y + c; % Differential Equation Anonymous Function
tspan = [0 5]; % Time Span
y0 = 0; % Initial Condition
[t,y] = ode45(f, tspan, y0); % Numerically Integrate ‘f(y)’
figure(1)
plot(t,y)
grid
See the documentation for ode45 for details.
4 Kommentare
siddharth tripathi
am 24 Jun. 2017
Its amazing star. I am going around looking at your solutions and liking them. LOl
Weitere Antworten (1)
arbia haded
am 16 Mai 2017
i would like to ask 2 quetions plz : 1- with ode45 can we solve a differential equation with spatial variation, for example the variation in the cartisian frame (x, y and z) 2- with ode45 can we solve a system like: dEz/dy-dEy/dz = a dEx/dz-dEz/dx = b dEy/dx-dEx/dy = c
i will be thankful if some one can help me
1 Kommentar
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!