Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

mukushla Group Title

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

  • one year ago
  • one year ago

  • This Question is Closed
  1. mukushla Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

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

    • one year ago
  2. mukushla Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @experimentX @phi

    • one year ago
  3. mukushla Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    any better ideas for that

    • one year ago
  4. experimentX Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    is it in matlab?

    • one year ago
  5. mukushla Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    yes Gauss-Jordan method

    • one year ago
  6. experimentX Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Hold on ... let me run!!

    • one year ago
  7. experimentX Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    what type of input does function take?

    • one year ago
  8. mukushla Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    a=n*n matrix b=1*n matrix

    • one year ago
  9. mukushla Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    hold on man its not working :) i thought its right

    • one year ago
  10. experimentX Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    do you put symbolic values for b?

    • one year ago
  11. experimentX Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    OH .. hell. I've been so forgetful.

    • one year ago
  12. experimentX Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • one year ago
  13. mukushla Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    lol

    • one year ago
  14. experimentX Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    you might be interested in this http://projecteuler.net/

    • one year ago
  15. phi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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

    • one year ago
    • Attachments:

See more questions >>>

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.