<?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: MATLAB Basics: Array of structures vs Structures of arrays</title>
	<atom:link href="http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/</link>
	<description>Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.</description>
	<lastBuildDate>Fri, 10 Feb 2012 20:31:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Ryan Gray</title>
		<link>http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-937</link>
		<dc:creator>Ryan Gray</dc:creator>
		<pubDate>Thu, 24 Apr 2008 19:31:14 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-937</guid>
		<description>If you have an array that you want to assign to a field across a structure array, you can do this:

[structArray(:).fieldname] = deal(num2cell(array))

Of course, the length of array should be the same as the length of structArray, but if structArray doesn&#039;t exist yet, then you can do:

[structArray(1:length(array)).fieldname] = deal(num2cell(array))

If array is already a cell array, you can avoid using both deal and num2cell (although they will still work) and use:

[structArray(:).fieldname] = array{:}
or
[structArray(1:length(array)).fieldname] = array{:}

An example, modifying the struct array &#039;people&#039; from the video:

names = {&#039;Larry&#039;,&#039;Moe&#039;,&#039;Curly&#039;};
[people(:).name] = names{:};</description>
		<content:encoded><![CDATA[<p>If you have an array that you want to assign to a field across a structure array, you can do this:</p>
<p>[structArray(:).fieldname] = deal(num2cell(array))</p>
<p>Of course, the length of array should be the same as the length of structArray, but if structArray doesn&#8217;t exist yet, then you can do:</p>
<p>[structArray(1:length(array)).fieldname] = deal(num2cell(array))</p>
<p>If array is already a cell array, you can avoid using both deal and num2cell (although they will still work) and use:</p>
<p>[structArray(:).fieldname] = array{:}<br />
or<br />
[structArray(1:length(array)).fieldname] = array{:}</p>
<p>An example, modifying the struct array &#8216;people&#8217; from the video:</p>
<p>names = {&#8216;Larry&#8217;,'Moe&#8217;,'Curly&#8217;};<br />
[people(:).name] = names{:};</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-940</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Wed, 23 Apr 2008 13:01:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-940</guid>
		<description>Emil,

Yes, you are correct.  I can not believe I over looked that.  There are so many ways to do certain things in MATLAB.

Doug</description>
		<content:encoded><![CDATA[<p>Emil,</p>
<p>Yes, you are correct.  I can not believe I over looked that.  There are so many ways to do certain things in MATLAB.</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-939</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Tue, 22 Apr 2008 21:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-939</guid>
		<description>This and Emil&#039;s comment were quite helpful to me.

To take this one step further, one advantage of Arrays of Structures would be the ability to have vectors of different lengths for each numerical part, and a cell array of names of different lengths for each name part.

For example:

people(1).name=&#039;Erin&#039;
people(2).name={&#039;Joan&#039; &#039;Carla&#039;}
people(1).sim=44
people(2).sim=[561 49]</description>
		<content:encoded><![CDATA[<p>This and Emil&#8217;s comment were quite helpful to me.</p>
<p>To take this one step further, one advantage of Arrays of Structures would be the ability to have vectors of different lengths for each numerical part, and a cell array of names of different lengths for each name part.</p>
<p>For example:</p>
<p>people(1).name=&#8217;Erin&#8217;<br />
people(2).name={&#8216;Joan&#8217; &#8216;Carla&#8217;}<br />
people(1).sim=44<br />
people(2).sim=[561 49]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Emil</title>
		<link>http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-938</link>
		<dc:creator>Emil</dc:creator>
		<pubDate>Tue, 22 Apr 2008 18:54:15 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-938</guid>
		<description>It&#039;s easier to create vector s by:
s = [people.SimmNum];</description>
		<content:encoded><![CDATA[<p>It&#8217;s easier to create vector s by:<br />
s = [people.SimmNum];</p>
]]></content:encoded>
	</item>
</channel>
</rss>

