Hi, MATLAB online solves this:
if true
% code
end
syms a h Y(x) g x B E
eqn = (h^2)*diff(Y,x, 2) + (2*i*h*g)*diff(Y,x) + (g^2 - E)*Y == 0;
DY = diff(Y)
cond1 = Y(0) == 1;
cond2 = DY(0) == 0;
Y(x) = dsolve(eqn, cond)
however MATLAB on the computer, 2017 a, does not solve it, and I get :
diff(Y(x), x)
Not enough input arguments.
Error in cond (line 24) if issparse(A)
Error in PDE_sol (line 6) Y(x) = dsolve(eqn, cond)
Which one should I "believe" in?

 採用された回答

Birdman
Birdman 2018 年 1 月 2 日

1 投票

Replace the line
Y(x) = dsolve(eqn, cond)
with
Y(x) = dsolve(eqn, [cond1 cond2])

9 件のコメント

Sergio Manzetti
Sergio Manzetti 2018 年 1 月 2 日
Thanks! Worked nicely!
Sergio Manzetti
Sergio Manzetti 2018 年 1 月 2 日
Birdman, something came up:
if true
% code
end
syms a h Y(x) g x B E
eqn = (h^2)*diff(Y,x, 2) + (2*i*h*g)*diff(Y,x) + (g^2 - E)*Y == 0;
DY = diff(Y)
D2Y = diff(Y,x, 2)
cond1 = Y(0) == 1;
cond2 = DY(0) == 0;
cond3 = Y(2*pi) == 1;
Y(x) = dsolve(eqn, cond)
gives
Y(x) =
C5*exp(-(x*(g*1i + (- 2*g^2 + E)^(1/2)))/h) + exp((g*1i - (- 2*g^2 + E)^(1/2))/h)*exp(-(x*(g*1i - (- 2*g^2 + E)^(1/2)))/h)*(pi - C5*exp(-(g*1i + (- 2*g^2 + E)^(1/2))/h))
on MATLAB online, while on comp with alpha 2017:
Y(2*pi) == 1
Warning: Explicit solution could not be found. > In dsolve (line 201) In PDE_sol (line 7)
Y(x) =
[ empty sym ]
Birdman
Birdman 2018 年 1 月 2 日
Firstly, change the last line to
Y(x) = dsolve(eqn, [cond1 cond2 cond3])
Secondly, supplying 2 initial condition as cond1 and cond3 seems to be wrong. What are you trying to find?
Torsten
Torsten 2018 年 1 月 2 日
Where did you define "cond" ?
Best wishes
Torsten.
Sergio Manzetti
Sergio Manzetti 2018 年 1 月 2 日
cond does not need to be defined, it's not there?
Sergio Manzetti
Sergio Manzetti 2018 年 1 月 2 日
Torsten, I want to apply some Boundary conditions to this, in order to find C. I checked MATLAB info on dsolve, but nothing is said about BCs.
Torsten
Torsten 2018 年 1 月 2 日
As Birdman said:
if true
% code
end
syms a h Y(x) g x B E
eqn = (h^2)*diff(Y,x, 2) + (2*i*h*g)*diff(Y,x) + (g^2 - E)*Y == 0;
DY = diff(Y)
D2Y = diff(Y,x, 2)
cond1 = Y(0) == 1;
cond2 = DY(0) == 0;
cond = [cond1 cond2];
Y(x) = dsolve(eqn, cond)
Prescribing three boundary conditions instead of two for a second-order equation will make the problem unsolvable in general:
if true
% code
end
syms a h Y(x) g x B E
eqn = (h^2)*diff(Y,x, 2) + (2*i*h*g)*diff(Y,x) + (g^2 - E)*Y == 0;
DY = diff(Y)
D2Y = diff(Y,x, 2)
cond1 = Y(0) == 1;
cond2 = DY(0) == 0;
cond3 = Y(2*pi) == 1;
cond = [cond1 cond2 cond3];
Y(x) = dsolve(eqn, cond)
Best wishes
Torsten.
Sergio Manzetti
Sergio Manzetti 2018 年 1 月 2 日
Thanks Torsten, I have to apply the BC's after solving the equation with the two ICs, and then extract the result.
Sana Syed
Sana Syed 2018 年 2 月 28 日
If I have 2 coupled 4th order non linear ODEs and 8 BCS it should take in the 8 conditions right? Its not accepting any of the boundary conditions which are non linear.
syms uy(x) txd(x) uz(x) ux(x); %Beam Dimensions Ty=0.001,Tz=0.01,L=0.1; %Constants based on dimensions from excel calculations c21=42.5015,c22=8.42*10^-4,c3=374.81,a=100,d=0.03; %Loading Conditions normalized loads fxl=0,fyl=0,myl=0,fzl=0,mzl=0,mxdl=0.3125,myl=0;%Pure twisting
%Differential Equations Input ode1=diff(uy,x,4)-fxl*diff(uy,x,2)==-myl*diff(txd,x,2)-2*fzl*diff(txd,x)+(1-x)*fzl*txd; %For pure twisting, it reduces to D4y/Dx4=0; ode2=(c21+c22*fxl)*diff(txd,x,2)-c3*diff(txd,x,4)-(myl-fzl*(1-x))*(mzl+fyl*(1-x)-fxl*(uy(L)-uy)-(myl-fzl*(1-x))*txd)==0; %ode2=(c21+c22*fxl)*diff(txd,x,2)-c3*diff(txd,x,4)==0; ode3=diff(uz,x,2)==txd*diff(uy,x,2)-(myl-fzl*(1-x))/a; %ode3=diff(uz,x,2)==txd*diff(uy,x,2)-(1/a)*(myl-fzl*(1-x)); ode4=d*(diff(ux,x)+0.5*(diff(uy,x))^2+0.5*(diff(uz,x))^2)+(((a+1)*(diff(txd,x))^2)/2)==fxl; %End of Differential Equations Input
%Define Derivative values in terms of variables Duy=diff(uy,x); D2uy=diff(uy,x,2); D3uy=diff(uy,x,3); Dtxd=diff(txd,x); D2txd=diff(txd,x,2); D3txd=diff(txd,x,3); Duz=diff(uz,x); D2uz=diff(uz,x,2); D3uz=diff(uz,x,3); %End of Derivative values in terms of variables
%Geometric Boundary Conditions cond1=ux(0)==0; cond2=uy(0)==0; cond3=uz(0)==0; cond4=txd(0)==0; cond5=Duz(0)==0; cond6=Duy(0)==0; cond7=Dtxd(0)==0; cond8=Dtxd(L)==0; %End of Geometric Boundary conditions
%Loading Boundary conditions
%THIS END CONDITION GIVES ERROR: cond9=-D3uy(L)-a*(2*txd(L)*Dtxd(L)*D2uy(L)+txd(L)^2*D3uy(L)-txd(L)*D3uz(L)-Dtxd(L)*D2txd(L))+fxl*Duy(L)==fyl;
%THIS CONDITION ALSO GIVES ERROR cond10=D2uy(L)+a*(txd(L)*D2uy(L)-D2uz(L))*txd(L)==mzl
cond11=-c3*D3txd(L)==mxdl;
%odes=[ode1 ode2 ode3 ode4]
odes=[ode1 ode2]
conds=[cond2 cond4 cond6 cond7 cond8]
%[uySol(x), txSol(x), uzSol(x), uxSol(x)] = dsolve(odes,conds)
[uySol(x), txSol(x)] = dsolve(odes,conds)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by