<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Video tutorial: 3d indexing</title>
	<link>http://blogs.mathworks.com/videos/2008/12/09/video-tutorial-3d-indexing/</link>
	<description>Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.</description>
	<pubDate>Mon, 23 Nov 2009 01:50:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Hassan</title>
		<link>http://blogs.mathworks.com/videos/2008/12/09/video-tutorial-3d-indexing/#comment-1259</link>
		<dc:creator>Hassan</dc:creator>
		<pubDate>Thu, 11 Dec 2008 00:57:24 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/12/09/video-tutorial-3d-indexing/#comment-1259</guid>
		<description>Found the error..should be
plhs[0]=mxCreateNumericArray(3,dims,mxDOUBLE_CLASS,mxREAL);

instead of

plhs[0]=mxCreateNumericArray(3,dims,mxINT16_CLASS,mxREAL);</description>
		<content:encoded><![CDATA[<p>Found the error..should be<br />
plhs[0]=mxCreateNumericArray(3,dims,mxDOUBLE_CLASS,mxREAL);</p>
<p>instead of</p>
<p>plhs[0]=mxCreateNumericArray(3,dims,mxINT16_CLASS,mxREAL);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hassan</title>
		<link>http://blogs.mathworks.com/videos/2008/12/09/video-tutorial-3d-indexing/#comment-1257</link>
		<dc:creator>Hassan</dc:creator>
		<pubDate>Wed, 10 Dec 2008 19:53:59 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/12/09/video-tutorial-3d-indexing/#comment-1257</guid>
		<description>I am have problem populating 3D matrix using mex file. I have a 3D int array

double *outArray;
dims[0]=4;dims[1]=2;dims[2]=3;

plhs[0]=mxCreateNumericArray(3,dims,mxINT16_CLASS,mxREAL);
outArray = mxGetPr(plhs[0]);
outArray[0]=12;

It gives random numbers in the output. If i do it using 2D matrix I have no problem.. any ideas?</description>
		<content:encoded><![CDATA[<p>I am have problem populating 3D matrix using mex file. I have a 3D int array</p>
<p>double *outArray;<br />
dims[0]=4;dims[1]=2;dims[2]=3;</p>
<p>plhs[0]=mxCreateNumericArray(3,dims,mxINT16_CLASS,mxREAL);<br />
outArray = mxGetPr(plhs[0]);<br />
outArray[0]=12;</p>
<p>It gives random numbers in the output. If i do it using 2D matrix I have no problem.. any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dhull</title>
		<link>http://blogs.mathworks.com/videos/2008/12/09/video-tutorial-3d-indexing/#comment-1256</link>
		<dc:creator>dhull</dc:creator>
		<pubDate>Wed, 10 Dec 2008 19:49:09 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/12/09/video-tutorial-3d-indexing/#comment-1256</guid>
		<description>Martin,

Yes,  in MATLAB there are often many ways of doing the same thing.  I do not know which one is faster, I suspect that the difference is negligible.

As you said, your code is harder to read, so that would make me want to do it another way.  Personally, I try to write code that is easy to read and understand.  Once it is working, then if there are sections that are slow, I will try more advanced maneuvers like you pointed out to trade readability for speed.

As always, thanks for reading and adding,
Doug</description>
		<content:encoded><![CDATA[<p>Martin,</p>
<p>Yes,  in MATLAB there are often many ways of doing the same thing.  I do not know which one is faster, I suspect that the difference is negligible.</p>
<p>As you said, your code is harder to read, so that would make me want to do it another way.  Personally, I try to write code that is easy to read and understand.  Once it is working, then if there are sections that are slow, I will try more advanced maneuvers like you pointed out to trade readability for speed.</p>
<p>As always, thanks for reading and adding,<br />
Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin le Roux</title>
		<link>http://blogs.mathworks.com/videos/2008/12/09/video-tutorial-3d-indexing/#comment-1255</link>
		<dc:creator>Martin le Roux</dc:creator>
		<pubDate>Wed, 10 Dec 2008 18:56:03 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/12/09/video-tutorial-3d-indexing/#comment-1255</guid>
		<description>What about the following:

[nR,nC] = size(J);
[r,c] = ndgrid(1:nR,1:nC);
M(sub2ind(size(M),r,c,J))

Admittedly it's harder to read, but it might be faster if J is large.</description>
		<content:encoded><![CDATA[<p>What about the following:</p>
<p>[nR,nC] = size(J);<br />
[r,c] = ndgrid(1:nR,1:nC);<br />
M(sub2ind(size(M),r,c,J))</p>
<p>Admittedly it&#8217;s harder to read, but it might be faster if J is large.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
