plotting an ODE with x limits and y limits.
Afficher commentaires plus anciens
Hello, I am trying to plot a differential equation with x-limits and y-limit that I set myself.
Not sure if this ODE would work but let's say
5y''+3y'+1=0 2<x<4 and 2<y<4
Réponses (1)
Walter Roberson
le 27 Fév 2017
syms y(x)
Dy = diff(y);
D2y = diff(Dy);
eqn = 5*D2y + 3*Dy + 1 == 0;
y0 = y(0) == 3; %need a boundary condition
Dy0 = Dy(0) == rand(); %need a boundary condition
F = dsolve(eqn, y0, Dy0)
fplot(F, [2 4])
ylim([2 4])
2 commentaires
Nadin Dimetry
le 28 Fév 2017
Modifié(e) : Walter Roberson
le 28 Fév 2017
Walter Roberson
le 28 Fév 2017
There does not appear to be an analytic solution to that equation (note: you would also need a few more boundary conditions to pin it down if there were a solution.)
You will need to work with one of the numeric solvers such as ode45()
Unfortunately I do not know how to translate the equations. Maybe
fun = @(y,x) [x(2);x(3);x(4);-x(1)*x(3)-y^2];
[Y, X] = ode45(fun, [0 4], [1;0;1;1]);
plot(Y, X(:,1))
after which you could put in xlim and ylim
Catégories
En savoir plus sur Numeric Solvers dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!