<?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: Vectorizing Access to an Array of Structures</title>
	<atom:link href="http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/</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>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-32598</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 07 Nov 2011 15:49:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-32598</guid>
		<description>Liuao-

The problem you are encountering is because your right-hand side is not a call that can be dealt out.  Try this instead:

&lt;pre class=&quot;code&quot;&gt;
c(3).x = []
[c.y] = c.x
d = 1:3
dc = num2cell(d)
[c.x] = dc{:}
c.x
&lt;/pre&gt;

--Loren</description>
		<content:encoded><![CDATA[<p>Liuao-</p>
<p>The problem you are encountering is because your right-hand side is not a call that can be dealt out.  Try this instead:</p>
<pre class="code">
c(3).x = []
[c.y] = c.x
d = 1:3
dc = num2cell(d)
[c.x] = dc{:}
c.x
</pre>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: liuao</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-32592</link>
		<dc:creator>liuao</dc:creator>
		<pubDate>Sat, 05 Nov 2011 12:01:36 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-32592</guid>
		<description>hi,now I have a question about assignment as the following:
I have a structure array named c size 3*1,whose fields is x and y,and now I have a array d size 3*1,then I want to assign
d to field x of c,how should I do?
I have try to type [c.x] = d,[c.x] =deal(d),c.x =d ,c.x=deal(d),but it all doesn&#039;t work.

Thank you and sorry for my poor english.</description>
		<content:encoded><![CDATA[<p>hi,now I have a question about assignment as the following:<br />
I have a structure array named c size 3*1,whose fields is x and y,and now I have a array d size 3*1,then I want to assign<br />
d to field x of c,how should I do?<br />
I have try to type [c.x] = d,[c.x] =deal(d),c.x =d ,c.x=deal(d),but it all doesn&#8217;t work.</p>
<p>Thank you and sorry for my poor english.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-31493</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Sun, 11 Jul 2010 20:13:51 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-31493</guid>
		<description>Vince-

That&#039;s similar to the way I would solve the problem as well - except I would not look for exact floating point numbers but within a range since there are numeric roundoff considerations to account for when working with floating point.  I also would probably use ismember with the rows option after getting the data out of the struct.

--Loren</description>
		<content:encoded><![CDATA[<p>Vince-</p>
<p>That&#8217;s similar to the way I would solve the problem as well &#8211; except I would not look for exact floating point numbers but within a range since there are numeric roundoff considerations to account for when working with floating point.  I also would probably use ismember with the rows option after getting the data out of the struct.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vince</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-31492</link>
		<dc:creator>Vince</dc:creator>
		<pubDate>Sun, 11 Jul 2010 11:23:27 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-31492</guid>
		<description>Hi Loren, 
I&#039;m new in using array of structures. I have an array of structures called &quot;list_uwv&quot;. Each structure has a field called &quot;cord&quot;, in which I&#039;ve placed a vector like this [a b c], where a,b,c are three numbers. My question is how can ask to the array of structures where is located the vector [A B C]; there is any function, like &quot;find&quot;, can I use for?
i.e 
&lt;pre&gt;
find(list_uwv.cord(:) == [0 3.5 0.8]))
&lt;/pre&gt;
Up to now I&#039;ve placed the vectors in a matrix (array of Nx3 elements) and I make the query to the matrix by using find function.
TNX a lot Loren</description>
		<content:encoded><![CDATA[<p>Hi Loren,<br />
I&#8217;m new in using array of structures. I have an array of structures called &#8220;list_uwv&#8221;. Each structure has a field called &#8220;cord&#8221;, in which I&#8217;ve placed a vector like this [a b c], where a,b,c are three numbers. My question is how can ask to the array of structures where is located the vector [A B C]; there is any function, like &#8220;find&#8221;, can I use for?<br />
i.e </p>
<pre>
find(list_uwv.cord(:) == [0 3.5 0.8]))
</pre>
<p>Up to now I&#8217;ve placed the vectors in a matrix (array of Nx3 elements) and I make the query to the matrix by using find function.<br />
TNX a lot Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30230</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 24 Apr 2009 16:39:13 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30230</guid>
		<description>Tom-

Thanks for the suggestion about the doc.  I will pass it on.

--Loren</description>
		<content:encoded><![CDATA[<p>Tom-</p>
<p>Thanks for the suggestion about the doc.  I will pass it on.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30228</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Fri, 24 Apr 2009 00:17:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30228</guid>
		<description>Sorry, the above is related to WHY THERE ARE SO MANY QUESTIONS IN THIS AREA.</description>
		<content:encoded><![CDATA[<p>Sorry, the above is related to WHY THERE ARE SO MANY QUESTIONS IN THIS AREA.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30227</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Fri, 24 Apr 2009 00:15:52 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30227</guid>
		<description>I think the biggest problem is the matlab help tells you how to BUILD a matrix/array/structure/string/cell but does not ON THE SAME PAGE tell you the syntax to get the data in such a type BACK OUT!!  Finding out how to get data OUT of these various storage types is not easy to find.  

I am a new user of matlab, and my biggest problem is getting the words I use in the help search function to relate to the words used as commands in the program...

ie &quot;How do I get data out of a structure&quot; does not give me an answer about structures 
   &quot;structure&quot; tells me how to build one, but not how to USE it, or how to get data inside a feild out and into a plot.  

Cheers, 
Tomas</description>
		<content:encoded><![CDATA[<p>I think the biggest problem is the matlab help tells you how to BUILD a matrix/array/structure/string/cell but does not ON THE SAME PAGE tell you the syntax to get the data in such a type BACK OUT!!  Finding out how to get data OUT of these various storage types is not easy to find.  </p>
<p>I am a new user of matlab, and my biggest problem is getting the words I use in the help search function to relate to the words used as commands in the program&#8230;</p>
<p>ie &#8220;How do I get data out of a structure&#8221; does not give me an answer about structures<br />
   &#8220;structure&#8221; tells me how to build one, but not how to USE it, or how to get data inside a feild out and into a plot.  </p>
<p>Cheers,<br />
Tomas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30090</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 05 Mar 2009 16:28:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30090</guid>
		<description>Jaime-

Look at arrayfun.  It might well be able to help you out here.

--Loren</description>
		<content:encoded><![CDATA[<p>Jaime-</p>
<p>Look at arrayfun.  It might well be able to help you out here.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jaime X. Ramos</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30083</link>
		<dc:creator>Jaime X. Ramos</dc:creator>
		<pubDate>Wed, 04 Mar 2009 17:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-30083</guid>
		<description>I have the same question as &#039;F. Moisy&#039; who replied on April 19th, 2007 at 15:01 UTC, except I have set of m x n matrices as field contents of a structure array.

I&#039;m gathering that I can only access say the (2,3) element for all structures in the array by iterating with a for loop, ie there&#039;s no compact access code like he wrote with
[struct.data(2,3)]

for i = 1:k
  struct(i).mat(2,3)
end

I&#039;m reading a tiff stack file using this matlab community user code and they store the frames as structures in a structure array. I&#039;m trying to compute the mode of a given pixel across all the frames but I can&#039;t see no way other than iteratively accessing that pixel.

Any ideas?


thanks for being such a champ! =)


Jaime</description>
		<content:encoded><![CDATA[<p>I have the same question as &#8216;F. Moisy&#8217; who replied on April 19th, 2007 at 15:01 UTC, except I have set of m x n matrices as field contents of a structure array.</p>
<p>I&#8217;m gathering that I can only access say the (2,3) element for all structures in the array by iterating with a for loop, ie there&#8217;s no compact access code like he wrote with<br />
[struct.data(2,3)]</p>
<p>for i = 1:k<br />
  struct(i).mat(2,3)<br />
end</p>
<p>I&#8217;m reading a tiff stack file using this matlab community user code and they store the frames as structures in a structure array. I&#8217;m trying to compute the mode of a given pixel across all the frames but I can&#8217;t see no way other than iteratively accessing that pixel.</p>
<p>Any ideas?</p>
<p>thanks for being such a champ! =)</p>
<p>Jaime</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KenA</title>
		<link>http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-29667</link>
		<dc:creator>KenA</dc:creator>
		<pubDate>Thu, 07 Aug 2008 16:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-29667</guid>
		<description>It may be worth point out that, in R2008a at least, the properties of an array of objects can be indexed as discussed in this blog posting.  To Mortiz’s post (27), this also not super-speedy, performing between the example’s “HybridTime” and “StructureTime”.  However, according “whos”, an array of classes is far more memory efficient than an equivalent array of structs.

So, if you find yourself creating a large array of structs, where those structs all have the same field names (homogeneous), an array of objects may be something to consider.</description>
		<content:encoded><![CDATA[<p>It may be worth point out that, in R2008a at least, the properties of an array of objects can be indexed as discussed in this blog posting.  To Mortiz’s post (27), this also not super-speedy, performing between the example’s “HybridTime” and “StructureTime”.  However, according “whos”, an array of classes is far more memory efficient than an equivalent array of structs.</p>
<p>So, if you find yourself creating a large array of structs, where those structs all have the same field names (homogeneous), an array of objects may be something to consider.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

