<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: All about the Colon Operator</title>
	<atom:link href="http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Fri, 17 Feb 2012 13:41:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Matlab user</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-32239</link>
		<dc:creator>Matlab user</dc:creator>
		<pubDate>Sat, 07 May 2011 11:17:11 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-32239</guid>
		<description>&lt;pre&gt;
[0:0.1:(5-11*eps)]
&lt;/pre&gt;
include 5 but
&lt;pre&gt;
[0:0.1:(5-10*eps)]
&lt;/pre&gt;
not include 5
the number for change here is a mystery!
&lt;pre&gt;
[0:0.1:(5-eps)]
&lt;/pre&gt;
must not include 5 floting point number, because eps is machine epsilon and 5 != (5-eps) is true
Very annoying.


Using two colons to create a vector with arbitrary real increments between the elements, 
E = 0:.1:.5
results in 
E =
    0    0.1000    0.2000    0.3000    0.4000    0.5000
This primer in help documentation about : operator must comment on this.
version 7 Matlab</description>
		<content:encoded><![CDATA[<pre>
[0:0.1:(5-11*eps)]
</pre>
<p>include 5 but</p>
<pre>
[0:0.1:(5-10*eps)]
</pre>
<p>not include 5<br />
the number for change here is a mystery!</p>
<pre>
[0:0.1:(5-eps)]
</pre>
<p>must not include 5 floting point number, because eps is machine epsilon and 5 != (5-eps) is true<br />
Very annoying.</p>
<p>Using two colons to create a vector with arbitrary real increments between the elements,<br />
E = 0:.1:.5<br />
results in<br />
E =<br />
    0    0.1000    0.2000    0.3000    0.4000    0.5000<br />
This primer in help documentation about : operator must comment on this.<br />
version 7 Matlab</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-31728</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 06 Oct 2010 10:59:43 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-31728</guid>
		<description>Olbert-

The term end is used for the last element.  So you can write:

&lt;pre class=&quot;code&quot;&gt;
array = ones(10,1);
%assume array length is unknown
offset = 5;
second_array = array(offset:end);
&lt;/pre&gt;

It&#039;s been available in MATLAB since version 5, I believe.
--Loren</description>
		<content:encoded><![CDATA[<p>Olbert-</p>
<p>The term end is used for the last element.  So you can write:</p>
<pre class="code">
array = ones(10,1);
%assume array length is unknown
offset = 5;
second_array = array(offset:end);
</pre>
<p>It&#8217;s been available in MATLAB since version 5, I believe.<br />
&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olbert</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-31726</link>
		<dc:creator>Olbert</dc:creator>
		<pubDate>Wed, 06 Oct 2010 06:43:37 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-31726</guid>
		<description>Maybe there is a way of referring to the last element of an array without actually knowing how long the array is.  Something like:
&lt;pre&gt;
second_array = array(offset:&#039;last&#039;)
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Maybe there is a way of referring to the last element of an array without actually knowing how long the array is.  Something like:</p>
<pre>
second_array = array(offset:'last')
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olbert</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-31725</link>
		<dc:creator>Olbert</dc:creator>
		<pubDate>Wed, 06 Oct 2010 06:40:02 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-31725</guid>
		<description>I deal with a lot of large arrays and matrices with Matlab.  Sometimes I want to use all the elements from some offset onwards or all of the elements up to a point.  At the moment my code looks something like this:

&lt;pre&gt;
array = ones(10,1);
%assume array length is unknown
length_of_array = length(array);
offset = 5;
second_array = array(offset:length_of_array);
&lt;/pre&gt;

Is there a better solution?  I would have thought it would look something like this - but it comes up with an error:

&lt;pre&gt;
array = ones(10,1);
offset = 5;
second_array = array(offset:);
&lt;/pre&gt;

Any help?</description>
		<content:encoded><![CDATA[<p>I deal with a lot of large arrays and matrices with Matlab.  Sometimes I want to use all the elements from some offset onwards or all of the elements up to a point.  At the moment my code looks something like this:</p>
<pre>
array = ones(10,1);
%assume array length is unknown
length_of_array = length(array);
offset = 5;
second_array = array(offset:length_of_array);
</pre>
<p>Is there a better solution?  I would have thought it would look something like this &#8211; but it comes up with an error:</p>
<pre>
array = ones(10,1);
offset = 5;
second_array = array(offset:);
</pre>
<p>Any help?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: michel bertrand</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-30895</link>
		<dc:creator>michel bertrand</dc:creator>
		<pubDate>Sun, 13 Dec 2009 20:25:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-30895</guid>
		<description>&lt;pre&gt;
a-repmat(mu,  1,size(a,2))
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre>
a-repmat(mu,  1,size(a,2))
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kishore</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-30685</link>
		<dc:creator>Kishore</dc:creator>
		<pubDate>Tue, 20 Oct 2009 23:38:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-30685</guid>
		<description>Thanks! Loren.</description>
		<content:encoded><![CDATA[<p>Thanks! Loren.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-30682</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Sun, 18 Oct 2009 18:09:38 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-30682</guid>
		<description>Kishore-

Take a look at the function &lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bsxfun.html&quot; rel=&quot;nofollow&quot;&gt;bsxfun&lt;/a&gt;.

--Loren</description>
		<content:encoded><![CDATA[<p>Kishore-</p>
<p>Take a look at the function <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bsxfun.html" rel="nofollow">bsxfun</a>.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kishore</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-30681</link>
		<dc:creator>Kishore</dc:creator>
		<pubDate>Sat, 17 Oct 2009 16:43:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-30681</guid>
		<description>Hi Loren,

greetings..


I need to subtarct 2 matrices..

&lt;pre&gt;

a =

     1     2     3
     4     5     6

and

mu =

     2
     5
&lt;/pre&gt;

how can i do in in 1 line..( i.e i do not want to use loops and subtract row by row..i.e subtarct each element of a row wise by element in mu)

i tried  using &quot;  a. - mu &quot; ,but it doesnt work ( not surprisingly!)

i answer i expect is 

 -1 0 1
 -1 0 1


Could u pls reply?

Thanks and Regards,
Kishore.</description>
		<content:encoded><![CDATA[<p>Hi Loren,</p>
<p>greetings..</p>
<p>I need to subtarct 2 matrices..</p>
<pre>

a =

     1     2     3
     4     5     6

and

mu =

     2
     5
</pre>
<p>how can i do in in 1 line..( i.e i do not want to use loops and subtract row by row..i.e subtarct each element of a row wise by element in mu)</p>
<p>i tried  using &#8221;  a. &#8211; mu &#8221; ,but it doesnt work ( not surprisingly!)</p>
<p>i answer i expect is </p>
<p> -1 0 1<br />
 -1 0 1</p>
<p>Could u pls reply?</p>
<p>Thanks and Regards,<br />
Kishore.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-28338</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 17 Apr 2008 14:33:38 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-28338</guid>
		<description>Tim-

You could use a while loop and and index that I bump by some increment.

&lt;pre&gt;
maxind = 10;
nums = zeros(1,maxind);
ind = 0;
while ind &lt; maxind
   ind = ind+1;
   nums(ind) = ind;
end
&lt;/pre&gt;

and obviously you can get more elaborate with starting, ending values and increment not being 1.

BUT, is there a reason to not use : ?

--Loren</description>
		<content:encoded><![CDATA[<p>Tim-</p>
<p>You could use a while loop and and index that I bump by some increment.</p>
<pre>
maxind = 10;
nums = zeros(1,maxind);
ind = 0;
while ind < maxind
   ind = ind+1;
   nums(ind) = ind;
end
</pre>
<p>and obviously you can get more elaborate with starting, ending values and increment not being 1.</p>
<p>BUT, is there a reason to not use : ?</p>
<p>--Loren</p>
</pre>]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://blogs.mathworks.com/loren/2006/11/10/all-about-the-colon-operator/#comment-22645</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Wed, 05 Dec 2007 06:26:29 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=65#comment-22645</guid>
		<description>It&#039;s easy to create a vector of numbers using a colon operator, but do you know how to create a sequence of numbers using only a loop and no colons?</description>
		<content:encoded><![CDATA[<p>It&#8217;s easy to create a vector of numbers using a colon operator, but do you know how to create a sequence of numbers using only a loop and no colons?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

