Proof-checking a ODE solution
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
2018년 1월 2일
Replace the line
Y(x) = dsolve(eqn, cond)
with
Y(x) = dsolve(eqn, [cond1 cond2])
댓글 수: 9
Thanks! Worked nicely!
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 ]
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
2018년 1월 2일
Where did you define "cond" ?
Best wishes
Torsten.
cond does not need to be defined, it's not there?
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.
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.
Thanks Torsten, I have to apply the BC's after solving the equation with the two ICs, and then extract the result.
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 Exchange에서 Equation Solving에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
