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 Center および File ExchangeNumeric Solvers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by