fourth order differential equation

조회 수: 14 (최근 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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by