Solving ODE Boundary Value Problem by Finite Difference Method
显示 更早的评论
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 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!