anonymous
  • anonymous
im ridiculous...i wrote this 3-4 years ago and now i cant figure it out !!!! this is for solving n linear equations with n unknowns
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
function G =GJ(a,b) w=length(a); if size(a,1)~=size(a,2) disp('This is not a n*n system!!!'); else for j=1:w for i=1:w if a(i,j)~=0 l(j)=i; end end end end c=[a b]; for m=1:w cm=c(m,:); c(m,:)=c(l(m),:); c(l(m),:)=cm; for n=1:w if l(n)==m l(n)=l(m); end end end for i=1:w-1 for j=i+1:w cj=c(j,:); ci=c(i,:); cj=cj-(c(j,i)/c(i,i))*ci; c(j,:)=cj; end end for i=w:-1:2 for j=i-1:-1:1 cj=c(j,:); ci=c(i,:); cj=cj-(c(j,i)/c(i,i))*ci; c(j,:)=cj; end end for i=1:w x(i)=c(i,w+1)/c(i,i); end c fprintf('%f\n',x);
anonymous
  • anonymous
@experimentX @phi
anonymous
  • anonymous
any better ideas for that

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

experimentX
  • experimentX
is it in matlab?
anonymous
  • anonymous
yes Gauss-Jordan method
experimentX
  • experimentX
Hold on ... let me run!!
experimentX
  • experimentX
what type of input does function take?
anonymous
  • anonymous
a=n*n matrix b=1*n matrix
anonymous
  • anonymous
hold on man its not working :) i thought its right
experimentX
  • experimentX
do you put symbolic values for b?
experimentX
  • experimentX
OH .. hell. I've been so forgetful.
experimentX
  • experimentX
Shouldn't this be easy ... since matlab stands for Matrix Laboratory still you managed to code it all. You should have done it in C perhaps ... lol. just joking.
anonymous
  • anonymous
lol
experimentX
  • experimentX
you might be interested in this http://projecteuler.net/
phi
  • phi
I assume you know \ Backslash or left matrix divide. A\B is the matrix division of A into B, which is roughly the same as INV(A)*B , except it is computed in a different way. If A is an N-by-N matrix and B is a column vector with N components, or a matrix with several such columns, then X = A\B is the solution to the equation A*X = B computed by Gaussian elimination. A warning message is printed if A is badly scaled or nearly singular. A\EYE(SIZE(A)) produces the inverse of A. Just for giggles: % gaussian elimination (not sophisticated) % ASSUMES square N x N matrix % tries not to divide by 0, but does not swap rows % create a 3x3 and a 3x1 a= rand(3); b= rand(3,1); c= [a b] % create the augmented matrix N= length(a); for ii=2:N jj= ii-1; % the pivot is c(jj,jj) on the diagonal c(1,1) is the 1st pivot % the next statement creates a submatrix (using an outer product) by % the key position (the position that will be zeroed out) for each % row. All positions below the pivot will be zeroed out by the % following statement. if (abs(c(jj,jj))>1e-12) % if non-zero use this pivot x= c(ii:end,jj)/c(jj,jj) * c(jj,jj:end); c(ii:end,jj:end)= c(ii:end,jj:end) - x; end; end; % Now work backwards. First normalize the pivot position to 1 % Then zero out all entries above the pivot position for jj=N:-1:1 ii= jj-1; if (abs(c(jj,jj))>1e-12) % if non-zero use this pivot c(jj,jj:end)= c(jj,jj:end)/c(jj,jj); x= c(1:ii,jj) * c(jj,jj:end); c(1:ii,jj:end)= c(1:ii,jj:end) - x; end; end; c(:,N+1:end) a\b % compare to Matlab's gaussian

Looking for something else?

Not the answer you are looking for? Search for more explanations.