How to solve this equation

3 views (last 30 days)
Raef
Raef on 30 Oct 2022
Commented: Raef on 31 Oct 2022
I need to solve the following differntinal equation:
y' = -(1+2n)y
intial condition y(0)=1 , n=1
  2 Comments
John D'Errico
John D'Errico on 30 Oct 2022
Surely you need to do your own homework assignment?
Raef
Raef on 30 Oct 2022
Its not my homework assignment, my dad is an applied mathematics scientist and has other colleagues that do the computer work which he don't know how to use. So im trying to learn to use matlab to help and contribute so this is the simple equation he gave me to solve and see if I get a result

Sign in to comment.

Accepted Answer

Sam Chak
Sam Chak on 30 Oct 2022
@Raef, you are a good son and took up a filial duty to help your father.
n = 1;
y0 = 1; % intial value
F = @(t, y) - (1 + 2*n)*y;
[t, y] = ode45(F, [0 5], y0);
plot(t, y), grid on, xlabel('t'), ylabel('y(t)')
  1 Comment
Raef
Raef on 31 Oct 2022
Thanks a lot for your words and answer

Sign in to comment.

More Answers (1)

Torsten
Torsten on 30 Oct 2022
Use pencil and paper.
dy/dt = -(1+2*n)*y
-> dy/y = -(1+2*n)*dt
-> log(y/y0) = -(1+2*n)*(t-t0)
-> y = ?
  3 Comments
Torsten
Torsten on 30 Oct 2022
Edited: Torsten on 30 Oct 2022
If you know the explicit form of the solution like from the approach with paper and pencil, you can easily graph it.
If you also have to derive the solution with a MATLAB solver, either use "dsolve" or "ode45".

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!