Jump to content

Meaning of : in Matlab

Featured Replies

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

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

Archived

This topic is now archived and is closed to further replies.

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.