I am currently working on a program for Gaussian elimination in Matlab for my numerical analysis class at FAMU. I am having problems understanding my errors in my code. My teacher told me to use a built in gauss elim function that I can not seem to find anywhere. Can anyone please help?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function x = gauss elim(A,b)
A = [4 -1 1; 2 5 2; 1 2 4];
b = [8; 3; 11];
n = size(A);
A = [A,b];
for i=1; n-1;
for j=i+1, n;
m=A(j,i)/A(i,i);
A(j,:)(not a happy face a colon and closing parenthesis) = A(j,:) - m*A(i,:);
end
end
x = zeros (n,1);
x(n) = A(n,n+1)/A(n,n);
dbstop
for i=n-1:-1:1;
x(i) = (A(i,n+1)-A(i,i+1:n)*x(i+1,n))/A(i,i);
end
disp(x)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SwiftlyMental 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.