function [ y ] = forward_elim( L, b )%performs gaussian foward elimination solving Ly=b using specific
%algorithm given
% Detailed explanation goes here
n = length(b);y= zeros (n,1);for i = 1:n i = i+1; %check to see that L is a valid matrix
if size (L) == size(L') % testing to see that L is a square matrix
if isnan(L) % if there is a not real number terminate
disp('error: invalid inputs in L') break elseif diag(L) == 0 % if a diagnol element of the matrix is 0 terminate
disp ('error: A diagnol element of L = 0') break end else disp('error: L is not a suqare matrix') break end sum = 0; for j = 1:i-1 sum = sum + L(i,j)*y(j); end y(i) = (b(i)- sum)/L(i,i) ; endend
MATLAB: For some reason every time I try to test the forward elimination function there is an error in the sum part, I cannot figure out why or what else I need to ad
forwardguassian
Best Answer