Jump to content

Meaning of : in Matlab


jasoncurious

Recommended Posts

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 by jasoncurious
Link to comment
Share on other sites

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 by D H
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.