フィルターのクリア

fourth order differential equation

25 ビュー (過去 30 日間)
kingcruises
kingcruises 2019 年 12 月 31 日
コメント済み: Star Strider 2020 年 1 月 2 日
syms f(x)
Df = diff(f,x);
D2f = diff(f,x,2);
D3f = diff(f,x,3);
D4f = diff(f,x,4);
ode =3*D4f+(2*x^2+6)*D3f+5*D2f-Df-2*f == - 4*x^6+ 2*x^5 -55*x^4 - 24*x^3 - 22*x^2 - x*32;
cond1 = f(0)==0;
cond2 = Df(0)==1;
cond3 = D2f(0) == -8;
cond4 = D3f(0) == 6;
conds = [cond1 cond2 cond3 cond4];
fSol(x) = dsolve(ode,conds);
figure
ezplot(fSol(x),[0 1])
The error is :
Warning: Unable to find explicit solution.
> In dsolve (line 201)
(line 13)
Error using inlineeval (line 14)
Error in inline expression ==> matrix([])
Undefined function 'matrix' for input arguments of type 'double'.
Error in inline/feval (line 33)
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ezplotfeval (line 51)
z = feval(f,x(1));
Error in ezplot>ezplot1 (line 486)
[y, f, loopflag] = ezplotfeval(f, x);
Error in ezplot (line 158)
[hp, cax] = ezplot1(cax, f{1}, vars, labels, args{:});
Error in sym/ezplot (line 78)
h = ezplot(fhandle(f),varargin{:});%#ok<EZPLT>
Error in try2 (line 15)
ezplot(fSol(x),[0 1])

採用された回答

Star Strider
Star Strider 2019 年 12 月 31 日
If an analytical solution is not an option, and a plot of the solution is the objectrive:
syms f(x) X Y
Df = diff(f,x);
D2f = diff(f,x,2);
D3f = diff(f,x,3);
D4f = diff(f,x,4);
ode =3*D4f+(2*x^2+6)*D3f+5*D2f-Df-2*f == - 4*x^6+ 2*x^5 -55*x^4 - 24*x^3 - 22*x^2 - x*32;
% cond1 = f(0)==0;
% cond2 = Df(0)==1;
% cond3 = D2f(0) == -8;
% cond4 = D3f(0) == 6;
[VF,Sbs] = odeToVectorField(ode);
odefcn = matlabFunction(VF, 'Vars',{x,Y});
[X,Y] = ode45(odefcn, [0 1], [0 1 -8 6]);
figure
plot(X, Y)
grid
legend(string(Sbs))
producing:
1fourth order differential equation - 2019 12 31.png
  15 件のコメント
kingcruises
kingcruises 2020 年 1 月 2 日
hey i must plot ode as a total not f, D2f, Df, D3f each one alone.
I want to plot ode as one graph
Star Strider
Star Strider 2020 年 1 月 2 日
The ‘method of moments’ was not part of my undergraduate or graduate education. (I had to look it up.) I will leave that part to you.
Plotting the total of the derivatives is straightforward. Only one change to my posted code is needed and that to sum across the columns in the plot call:
[X,Y] = ode45(odefcn, [0 1], [0 1 -8 6]);
figure
plot(X, sum(Y,2))
grid
That should do what you want.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by