A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 3 years ago
im ridiculous...i wrote this 34 years ago and now i cant figure it out !!!! this is for solving n linear equations with n unknowns
anonymous
 3 years ago
im ridiculous...i wrote this 34 years ago and now i cant figure it out !!!! this is for solving n linear equations with n unknowns

This Question is Closed

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0function 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:w1 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=i1: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
 3 years ago
Best ResponseYou've already chosen the best response.0any better ideas for that

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0yes GaussJordan method

experimentX
 3 years ago
Best ResponseYou've already chosen the best response.0Hold on ... let me run!!

experimentX
 3 years ago
Best ResponseYou've already chosen the best response.0what type of input does function take?

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0a=n*n matrix b=1*n matrix

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0hold on man its not working :) i thought its right

experimentX
 3 years ago
Best ResponseYou've already chosen the best response.0do you put symbolic values for b?

experimentX
 3 years ago
Best ResponseYou've already chosen the best response.0OH .. hell. I've been so forgetful.

experimentX
 3 years ago
Best ResponseYou've already chosen the best response.0Shouldn'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.

experimentX
 3 years ago
Best ResponseYou've already chosen the best response.0you might be interested in this http://projecteuler.net/

phi
 3 years ago
Best ResponseYou've already chosen the best response.0I 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 NbyN 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= ii1; % 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))>1e12) % if nonzero 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= jj1; if (abs(c(jj,jj))>1e12) % if nonzero 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
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.