Solving ODE Boundary Value Problem by Finite Difference Method
조회 수: 11 (최근 30일)
이전 댓글 표시
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
채택된 답변
Alan Stevens
2021년 10월 31일
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);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 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!