Solving ODE Boundary Value Problem by Finite Difference Method
69 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Musa Abedrabbo
el 31 de Oct. de 2021
Comentada: Musa Abedrabbo
el 31 de Oct. de 2021
Im solving the Euler Bernoulli Beam ODE: y'' - Ty/EI = wx(L-x)/2EI with bound y(0) = 0 and y(L) = 0. I determined the coefficents of the y variables but my matrix for the thrid row is all zeros when it should be the same as the second row but shifted a column. I suspect an indexing issue but Im not sure. Also my code for the elements in the product matrix is giving me an index error as well. Any advice is appreciated, heres my code.
%ODE: y'' - Ty/EI = wx(L-x)/2EI
T = 7200;
w = 5400;
L = 75;
E = 30*10^6;
I = 120;
%Divisons of Boundary
N = 3;
%Boundary conditions
y0 = 0;
yn = 0;
%Step Size
h = L/N;
%Intializations
x = linspace(0, L, N+1);
A = zeros(N+1, N+1);
b = zeros(N+1, 1);
A(1, 1) = 1;
b(1) = y0;
A(N+1, N+1) = 1;
b(N+1) = yn;
for i = 1:(N-1)
xi = x(i+1);
%coefficients of (yi-1, yi, and yi+1)
c0 = 1/(h^2);
c1 = -2/(h^2) - T/(E*I);
c2 = 1/(h^2);
A(i+1, i) = c0;
A(i+1, i+1) = c1;
A(i+1, i+2) = c2;
b(i+1) = (w*xi(L-xi))/(2*E*I);
end
y = A \ b;
0 comentarios
Respuesta aceptada
Alan Stevens
el 31 de Oct. de 2021
I think you just need to change
b(i+1) = (w*xi(L-xi))/(2*E*I);
to
b(i+1) = (w*xi*(L-xi))/(2*E*I);
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!