jasoncurious Posted December 7, 2012 Posted December 7, 2012 (edited) Hi guys, I am currently doing a Matlab program for scaled partial pivoting. I looked at my friend's example: % Partial Pivoting for i=1:n-1 for j = i+1:n if (a(j,i)) > (a(i,i)) u=a(i,; a(i,=a(j,; a(j,=u; v=b(i,1); b(i,1)=b(j,1); b(j,1)=v; end end end I was wondering what is the meaning of the :? Previously I have come across a few times this thing, but I don't know what it stands for. Is it some sort of Matlab keyword? Edited December 7, 2012 by jasoncurious
D H Posted December 7, 2012 Posted December 7, 2012 (edited) The colon operator creates a set. In for i = 1:n-1 the colon operator creates the set of integers between 1 and n-1, inclusive, and then iterates over the elements of that set. The colon operator in u=a(i,: ) the colon operator is equivalent to u=a(i,1:end). This takes a slice of the matrix a. Edited December 7, 2012 by D H
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now