Insights Blog
-- Browse All Articles --
Physics Articles
Physics Tutorials
Physics Guides
Physics FAQ
Math Articles
Math Tutorials
Math Guides
Math FAQ
Education Articles
Education Guides
Bio/Chem Articles
Technology Guides
Computer Science Tutorials
Forums
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Trending
Featured Threads
Log in
Register
What's new
Search
Search
Search titles only
By:
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Menu
Log in
Register
Navigation
More options
Contact us
Close Menu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Homework Help
Engineering and Comp Sci Homework Help
Matlab Gaussian elimination with partial pivoting
Reply to thread
Message
[QUOTE="NewAlias, post: 2799131, member: 251078"] [h2]Homework Statement [/h2] Hi all, I'm writing a program to solve a system of linear algebraic equations using the method of Gaussian elimination. The only thing I can't figure out is how to perform the actual pivot. In the %Forward elimination nest, I can't figure out how I am supposed to find the max_row. Is it just any row that has the maximum value or is it specific to the pivot row? Most of the function is translated from pseudo code posted by my professor and the only part I can't translate is how to get the max_row. Any help would be greatly appreciated! [h2]Homework Equations[/h2] [code=matlab] function x=Lab7gauss(A,b) %Solves a given system of linear equations Ax=b using the Gauss Elimination %method. Equations in format Ax=b.%Function code A=input('Enter the coefficient matrix: '); b=input('Enter the right hand side vector b: '); [m,n]=size(A); if m~=n error('Coefficient matrix A must be square') end Ab=[A,b]; nc=n+1; %Forward elimination for p=1:n-1 %p is current pivot row %partial pivoting max_row=max(A); if max_row~=p p=max_row; max_row=p; end for i=p+1:n %operate on all rows below pivot factor = Ab(i,p)/Ab(p,p); for c=p:nc Ab(i,c)=Ab(i,c)-factor*Ab(p,c); end end end %back substitution x(n)=Ab(n,nc)/Ab(n,n); for k=n-1:-1:1 x(k)=Ab(k,nc); for j=k+1:n x(k)=x(k)-Ab(k,j)*x(j); end x(k)=x(k)/Ab(k,k); end [C,I]=max(A) [/code] [/QUOTE]
Insert quotes…
Post reply
Forums
Homework Help
Engineering and Comp Sci Homework Help
Matlab Gaussian elimination with partial pivoting
Back
Top