bvp4c Boundary Condition Issues
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I'm trying to solve the following non linear ode with bvp4c:
y" + (P/(E*I))y = 0;
Where I is a known function of x, E is known constant, and P is an unknown constant. The following B.C.s exist:
y(0) = 0, y(L) = 0, y"(0) = 0
I want to use the following code to solve for P, but I get an error saying that the index ya(3) is out of bounds. Does bvp4c not work with second order boundary conditions? Does anyone know of any workarounds or other functions that could solve my problem?
P = pi^2*mean(I)*E/L^2;
dx = X(2) - X(1);
solinit = bvpinit(X,@mat4init,P);
sol = bvp4c(@mat4ode,@mat4bc,solinit);
Sxint = deval(sol,X);
Sxint = Sxint(1,:);
plot(Sxint)
disp(P)
function dydx = mat4ode(x,y,P)
Index = round(x/dx) + 1;
dydx = [ y(2)
- P*y(1)/(E*I(Index)) ];
end
function res = mat4bc(ya,yb,P)
res = [ ya(1)
yb(1)
ya(3) ];
end
function yinit = mat4init(x)
yinit = [ sin(x*pi/L)
pi/L*cos(x*pi/L) ];
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Boundary Value Problems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!