plotting an ODE with x limits and y limits.

2 visualizaciones (últimos 30 días)
Nadin Dimetry
Nadin Dimetry el 27 de Feb. de 2017
Comentada: Walter Roberson el 28 de Feb. de 2017
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

Respuestas (1)

Walter Roberson
Walter Roberson el 27 de Feb. de 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 comentarios
Nadin Dimetry
Nadin Dimetry el 28 de Feb. de 2017
Editada: Walter Roberson el 28 de Feb. de 2017
I changed the equation and it wouldn't give me any plots
clear
syms y(x)
Dy = diff(y);
D2y = diff(Dy);
D3y = diff(D2y);
D4y = diff(D3y);
eqn = -D4y-y^2-x*D2y == 0;
y0 = y(0) == 1; %need a boundary condition
Dy0 = Dy(0) == 0; %need a boundary condition
F = dsolve(eqn, y(0), Dy(0)
fplot(F, [2 4])
ylim([2 4])
Also, how else would you graph this without using symbolic ?
Walter Roberson
Walter Roberson el 28 de Feb. de 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

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by