plotting an ODE with x limits and y limits.

조회 수: 2 (최근 30일)
Nadin Dimetry
Nadin Dimetry 2017년 2월 27일
댓글: Walter Roberson 2017년 2월 28일
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

답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 27일
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
Nadin Dimetry
Nadin Dimetry 2017년 2월 28일
편집: Walter Roberson 2017년 2월 28일
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 2017년 2월 28일
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

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

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by