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)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

If you bothered searching for "Gaussian Elimination matlab" on Google and looking at some of the results, you'd learn that you can use the \ operator to solve your problem, and searching for "matlab operators" would give you a result with specific information.

I have looked at others examples on matlab. He gave us an algorithm that we must use. It has a predefined gauss elim function that I have not seen anywhere else. It is giving me an error as well.

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.