bvp4c Boundary Condition Issues
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Boundary Value Problems in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!