<?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: MATLAB Basics: Array of structures vs Structures of arrays</title>
	<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>
	<pubDate>Mon, 23 Nov 2009 01:03:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.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>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'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 'people' from the video:

names = {'Larry','Moe','Curly'};
[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 = {&#8217;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>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>http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-939</guid>
		<description>This and Emil'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='Erin'
people(2).name={'Joan' 'Carla'}
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={&#8217;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>http://blogs.mathworks.com/videos/2008/04/22/matlab-basics-array-of-structures-vs-structures-of-arrays/#comment-938</guid>
		<description>It'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>
