How to solve y'=y^2+3y-2 for some y(0)

4 views (last 30 days)
Backtobasics
Backtobasics on 3 Sep 2017
Commented: Walter Roberson on 4 Sep 2017
Hi there,
I want/have to solve the following diff. equation y'=y^2+3y-2 for y1(0)=2, y2(0)=5 and y3(0)=6. I am new to MATLAB so I don't really know how to do that. I know that I have to use ode etc. but I keep getting various errors so I haven't understood the basic concept yet. I hope that some of you guys can help me out? Not necessarily the solution but maybe some hints.
Best

Answers (1)

Walter Roberson
Walter Roberson on 3 Sep 2017
syms y(x) y0
Y = dsolve(diff(y)==y^2+3*y-2, y(0)==y0);
simplify( subs(Y, y0, 2) )
simplify( subs(Y, y0, 6) )
  2 Comments
Backtobasics
Backtobasics on 3 Sep 2017
Thank you for your response! I have to solve it numerically tho and plot the curves and as far as I understand, dsolve is an analytical solution, isn't it?
Walter Roberson
Walter Roberson on 4 Sep 2017
ode45( @(t, y) y.^2 + 3*y - 2, [0 1], 2 )
Note: there is a singularity at about 0.328

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!