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

 채택된 답변

Star Strider
Star Strider 2016년 7월 26일

1 개 추천

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

jone
jone 2016년 7월 26일
Thank you Star Strider for your answer it is helpful
Star Strider
Star Strider 2016년 7월 26일
My pleasure.
siddharth tripathi
siddharth tripathi 2017년 6월 24일
Its amazing star. I am going around looking at your solutions and liking them. LOl
Star Strider
Star Strider 2017년 6월 24일
Thank you very much!

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

추가 답변 (1개)

arbia haded
arbia haded 2017년 5월 16일

0 개 추천

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

Torsten
Torsten 2017년 5월 16일
편집: Torsten 2017년 5월 16일
No. ode45 solves ordinary differential equations.
What you have is a system of partial differential equations.
Best wishes
Torsten.

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

카테고리

질문:

2016년 7월 26일

댓글:

2017년 6월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by