<?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: Cute Tricks in MATLAB Adapted from Other Languages</title>
	<atom:link href="http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/</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>Mon, 13 Feb 2012 13:24:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Bryan</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-32173</link>
		<dc:creator>Bryan</dc:creator>
		<pubDate>Sat, 02 Apr 2011 21:09:18 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-32173</guid>
		<description>This is my code, it lets the user plot 3 points 4 times and then it plots them!
Here it is:
&lt;pre&gt;
[x,y] = ginput(3);
msgbox(sprintf(&#039;Value 1 set&#039;));
pause(1.9)
[x2,y2] = ginput(3);
msgbox(sprintf(&#039;Value 2 set&#039;));
pause(1.9)
[x3,y3] = ginput(3);
msgbox(sprintf(&#039;Value 3 set&#039;));
pause(1.9)
[x4,y4] = ginput(3);
msgbox(sprintf(&#039;Value 4 set&#039;));
pause(1.9)
msgbox(sprintf(&#039;Plotting...&#039;));
pause(2.5)
msgbox(sprintf(&#039;Plotted!&#039;));
plot(x,y,x2,y2,x3,y3,x4,y4)
h = rotate3d;
set(h,&#039;RotateStyle&#039;,&#039;box&#039;,&#039;Enable&#039;,&#039;on&#039;);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>This is my code, it lets the user plot 3 points 4 times and then it plots them!<br />
Here it is:</p>
<pre>
[x,y] = ginput(3);
msgbox(sprintf('Value 1 set'));
pause(1.9)
[x2,y2] = ginput(3);
msgbox(sprintf('Value 2 set'));
pause(1.9)
[x3,y3] = ginput(3);
msgbox(sprintf('Value 3 set'));
pause(1.9)
[x4,y4] = ginput(3);
msgbox(sprintf('Value 4 set'));
pause(1.9)
msgbox(sprintf('Plotting...'));
pause(2.5)
msgbox(sprintf('Plotted!'));
plot(x,y,x2,y2,x3,y3,x4,y4)
h = rotate3d;
set(h,'RotateStyle','box','Enable','on');
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-31261</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Sun, 11 Apr 2010 18:51:52 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-31261</guid>
		<description>Adam-

eps for your system is something like 2.2e-16 most likely, so you are seeing differences because of the details of the numerics.  Break the two expressions into pieces and evaluate in chunks (e.g., (1+1/x-1) and 1/(1+1/x-1) vs. the expression in your first statement.  I get 1.11022302462516e-015 for (1+1/x-1) instead of what I think you&#039;re expecting 1e-15 because of the order of operations - the difference in between the 2 expressions is about eps/2.

When you are working at this margin, you need to be careful with calculations and the order in which they are done.  Numerically, they are not associative.

--Loren</description>
		<content:encoded><![CDATA[<p>Adam-</p>
<p>eps for your system is something like 2.2e-16 most likely, so you are seeing differences because of the details of the numerics.  Break the two expressions into pieces and evaluate in chunks (e.g., (1+1/x-1) and 1/(1+1/x-1) vs. the expression in your first statement.  I get 1.11022302462516e-015 for (1+1/x-1) instead of what I think you&#8217;re expecting 1e-15 because of the order of operations &#8211; the difference in between the 2 expressions is about eps/2.</p>
<p>When you are working at this margin, you need to be careful with calculations and the order in which they are done.  Numerically, they are not associative.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-31259</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Fri, 09 Apr 2010 18:56:22 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-31259</guid>
		<description>Hi,
I&#039;m trying to calculate( or evaluate) Euler constant (e) in this way:
x=10^15
res=(1+1/x)^x

res=3.03..

while when making x=10^13, I get a better evaluation: 2.71..
when mathematically isnt making sense.

In addition, when trying this equivalent expression:
x=10^15
res=(1+1/x)^(1/(1+1/x-1))
I get res = 2.71.. which is way better then the equivalent expression above.
Do you have an explanation for this?

Thanks,
Adam</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I&#8217;m trying to calculate( or evaluate) Euler constant (e) in this way:<br />
x=10^15<br />
res=(1+1/x)^x</p>
<p>res=3.03..</p>
<p>while when making x=10^13, I get a better evaluation: 2.71..<br />
when mathematically isnt making sense.</p>
<p>In addition, when trying this equivalent expression:<br />
x=10^15<br />
res=(1+1/x)^(1/(1+1/x-1))<br />
I get res = 2.71.. which is way better then the equivalent expression above.<br />
Do you have an explanation for this?</p>
<p>Thanks,<br />
Adam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-29882</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 21 Nov 2008 14:33:50 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-29882</guid>
		<description>Ljubomir-

The bitops originally worked on doubles since that&#039;s all MATLAB had.  When the other numeric datatypes were added, the bitops were expanded to the integer types which were the intended input values.  Singles got passed by.  Perhaps you could create an enhancement request for this functionality, explaining the situation when the need arises for you.

--Loren</description>
		<content:encoded><![CDATA[<p>Ljubomir-</p>
<p>The bitops originally worked on doubles since that&#8217;s all MATLAB had.  When the other numeric datatypes were added, the bitops were expanded to the integer types which were the intended input values.  Singles got passed by.  Perhaps you could create an enhancement request for this functionality, explaining the situation when the need arises for you.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ljubomir Josifovski</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-29881</link>
		<dc:creator>Ljubomir Josifovski</dc:creator>
		<pubDate>Fri, 21 Nov 2008 14:24:13 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-29881</guid>
		<description>Somewhat related as it involves bit functions and did not find more relevant bitops thread. :-)

It is a bit annoying that bitops on doubles are supoprted out of the box, ex:

&gt;&gt; a=double(1);b=double(2);c=bitor(a,b);c,whos a b c
c = 3
  Name      Size            Bytes  Class     Attributes
  a         1x1                 8  double              
  b         1x1                 8  double              
  c         1x1                 8  double              

while single-s seem to be less loved:

&gt;&gt; a=single(1);b=single(2);c=bitor(a,b);c,whos a b c
??? Undefined function or method &#039;bitor&#039; for input arguments of type &#039;single&#039;.

Of course, one can always

&gt;&gt; a=single(1);b=single(2);c=single(bitor(double(a),double(b)));c,whos a b c
c = 3
  Name      Size            Bytes  Class     Attributes
  a         1x1                 4  single              
  b         1x1                 4  single              
  c         1x1                 4  single              

but that involves chasing down every single line of user code. :-)

Is there maybe an easy way to &quot;add&quot; bitops support for singles without changing the callee? Like write bitop functions wrappers that accept singles? Expect not but thought I&#039;d better ask just in case.

Thanks in advance for your help.

Regards,
Ljubomir</description>
		<content:encoded><![CDATA[<p>Somewhat related as it involves bit functions and did not find more relevant bitops thread. :-)</p>
<p>It is a bit annoying that bitops on doubles are supoprted out of the box, ex:</p>
<p>&gt;&gt; a=double(1);b=double(2);c=bitor(a,b);c,whos a b c<br />
c = 3<br />
  Name      Size            Bytes  Class     Attributes<br />
  a         1&#215;1                 8  double<br />
  b         1&#215;1                 8  double<br />
  c         1&#215;1                 8  double              </p>
<p>while single-s seem to be less loved:</p>
<p>&gt;&gt; a=single(1);b=single(2);c=bitor(a,b);c,whos a b c<br />
??? Undefined function or method &#8216;bitor&#8217; for input arguments of type &#8216;single&#8217;.</p>
<p>Of course, one can always</p>
<p>&gt;&gt; a=single(1);b=single(2);c=single(bitor(double(a),double(b)));c,whos a b c<br />
c = 3<br />
  Name      Size            Bytes  Class     Attributes<br />
  a         1&#215;1                 4  single<br />
  b         1&#215;1                 4  single<br />
  c         1&#215;1                 4  single              </p>
<p>but that involves chasing down every single line of user code. :-)</p>
<p>Is there maybe an easy way to &#8220;add&#8221; bitops support for singles without changing the callee? Like write bitop functions wrappers that accept singles? Expect not but thought I&#8217;d better ask just in case.</p>
<p>Thanks in advance for your help.</p>
<p>Regards,<br />
Ljubomir</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-22475</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Sat, 01 Dec 2007 13:10:22 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-22475</guid>
		<description>Marko-

Perhaps you could take this discussion off-line or with technical support as it is not on-topic for this blog article. Thank you.

-Loren</description>
		<content:encoded><![CDATA[<p>Marko-</p>
<p>Perhaps you could take this discussion off-line or with technical support as it is not on-topic for this blog article. Thank you.</p>
<p>-Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marko</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-22457</link>
		<dc:creator>marko</dc:creator>
		<pubDate>Sat, 01 Dec 2007 09:43:41 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-22457</guid>
		<description>OK! very nice! Thank you for you help...but i have another questions, if you dont mind: how can i matlab open and save raw image files (iamge.raw)?</description>
		<content:encoded><![CDATA[<p>OK! very nice! Thank you for you help&#8230;but i have another questions, if you dont mind: how can i matlab open and save raw image files (iamge.raw)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Eddins</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-22437</link>
		<dc:creator>Steve Eddins</dc:creator>
		<pubDate>Fri, 30 Nov 2007 19:13:49 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-22437</guid>
		<description>Marko&#8212;uint16 does the operation you describe.  typecast does not.</description>
		<content:encoded><![CDATA[<p>Marko&mdash;uint16 does the operation you describe.  typecast does not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marko</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-22434</link>
		<dc:creator>marko</dc:creator>
		<pubDate>Fri, 30 Nov 2007 18:20:53 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-22434</guid>
		<description>but this function really does the upper (most important byte) equal to 0? i found that for example you can do this with &quot;typecast&quot; function, which combine 2 uint8 values to one uint16 and you have control on byte value and byte order...</description>
		<content:encoded><![CDATA[<p>but this function really does the upper (most important byte) equal to 0? i found that for example you can do this with &#8220;typecast&#8221; function, which combine 2 uint8 values to one uint16 and you have control on byte value and byte order&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Eddins</title>
		<link>http://blogs.mathworks.com/loren/2006/10/25/cute-tricks-in-matlab-adapted-from-other-languages/#comment-22433</link>
		<dc:creator>Steve Eddins</dc:creator>
		<pubDate>Fri, 30 Nov 2007 18:09:25 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=60#comment-22433</guid>
		<description>Marko&#8212;Use the uint16 function.</description>
		<content:encoded><![CDATA[<p>Marko&mdash;Use the uint16 function.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

