<?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: Working with structs</title>
	<atom:link href="http://blogs.mathworks.com/loren/2006/03/08/working-with-structs/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2006/03/08/working-with-structs/</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: Jiro Doke</title>
		<link>http://blogs.mathworks.com/loren/2006/03/08/working-with-structs/#comment-73</link>
		<dc:creator>Jiro Doke</dc:creator>
		<pubDate>Thu, 09 Mar 2006 17:08:31 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=26#comment-73</guid>
		<description>Andrew,
Yes, if the original check is there, then that out be shorter. We can combine everything, and say:

if ~isstruct(D) &#124;&#124; ...
    ~isequal(sort(fieldnames(D)),{’amplitude’;&#039;time’})
   error(&#039;snippet:incorrectInput&#039;, ...
        &#039;snippet expects a struct with only fields time and amplitude&#039;);
end</description>
		<content:encoded><![CDATA[<p>Andrew,<br />
Yes, if the original check is there, then that out be shorter. We can combine everything, and say:</p>
<p>if ~isstruct(D) || &#8230;<br />
    ~isequal(sort(fieldnames(D)),{’amplitude’;&#8217;time’})<br />
   error(&#8216;snippet:incorrectInput&#8217;, &#8230;<br />
        &#8216;snippet expects a struct with only fields time and amplitude&#8217;);<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Newell</title>
		<link>http://blogs.mathworks.com/loren/2006/03/08/working-with-structs/#comment-72</link>
		<dc:creator>Andrew Newell</dc:creator>
		<pubDate>Thu, 09 Mar 2006 15:27:03 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=26#comment-72</guid>
		<description>Here is a shorter test:
if length(fieldnames(D)) &gt; 2

Andrew</description>
		<content:encoded><![CDATA[<p>Here is a shorter test:<br />
if length(fieldnames(D)) &gt; 2</p>
<p>Andrew</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/03/08/working-with-structs/#comment-71</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 09 Mar 2006 12:50:52 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=26#comment-71</guid>
		<description>Though the syntax looks the same, the mechanism in MATLAB is quite different.  I don&#039;t have any immediate suggestions here but you might contact our technical support team to see if they have something that might help you out.
&lt;p&gt;
http://www.mathworks.com/support/contact_us/ts/help_request_1.html</description>
		<content:encoded><![CDATA[<p>Though the syntax looks the same, the mechanism in MATLAB is quite different.  I don&#8217;t have any immediate suggestions here but you might contact our technical support team to see if they have something that might help you out.</p>
<p>
<a href="http://www.mathworks.com/support/contact_us/ts/help_request_1.html" rel="nofollow">http://www.mathworks.com/support/contact_us/ts/help_request_1.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Markus</title>
		<link>http://blogs.mathworks.com/loren/2006/03/08/working-with-structs/#comment-70</link>
		<dc:creator>Markus</dc:creator>
		<pubDate>Thu, 09 Mar 2006 11:38:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=26#comment-70</guid>
		<description>Hi!

Am working intensely with classes and objects in my MATLAB projects. As you wrote about structures which are somehow similar, I thought my question could fit in here.

When referencing or changing a field of an object, I want to use a simple dot notation like x = obj.x or obj.x = x from whatever function I am in, thus I need to implement the functions subsref.m (subscripted reference) and subsasgn.m (subscripted assignment). In my work, these functions look the same for all classes:

  function value = subsref(obj, S)
  value = subsref(struct(obj), S);

  function obj = subsasgn(obj, S, value)
  obj = builtin(&#039;subsasgn&#039;, obj, S, value);

Unfortunately, the object field access is very slow, orders of magnitude slower than accessing fields of a structure. The profiler shows that the amount of time spent for accessing fields in my project is everything else than neglible.

Do you have any suggestions how to speed up field access?

Regards
Markus</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>Am working intensely with classes and objects in my MATLAB projects. As you wrote about structures which are somehow similar, I thought my question could fit in here.</p>
<p>When referencing or changing a field of an object, I want to use a simple dot notation like x = obj.x or obj.x = x from whatever function I am in, thus I need to implement the functions subsref.m (subscripted reference) and subsasgn.m (subscripted assignment). In my work, these functions look the same for all classes:</p>
<p>  function value = subsref(obj, S)<br />
  value = subsref(struct(obj), S);</p>
<p>  function obj = subsasgn(obj, S, value)<br />
  obj = builtin(&#8216;subsasgn&#8217;, obj, S, value);</p>
<p>Unfortunately, the object field access is very slow, orders of magnitude slower than accessing fields of a structure. The profiler shows that the amount of time spent for accessing fields in my project is everything else than neglible.</p>
<p>Do you have any suggestions how to speed up field access?</p>
<p>Regards<br />
Markus</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jiro Doke</title>
		<link>http://blogs.mathworks.com/loren/2006/03/08/working-with-structs/#comment-68</link>
		<dc:creator>Jiro Doke</dc:creator>
		<pubDate>Wed, 08 Mar 2006 22:39:33 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=26#comment-68</guid>
		<description>Hi,

I love extra credit!

How about:

if ~isequal(sort(fieldnames(D)),{&#039;amplitude&#039;;&#039;time&#039;})
  error(...)
end



jiro</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I love extra credit!</p>
<p>How about:</p>
<p>if ~isequal(sort(fieldnames(D)),{&#8216;amplitude&#8217;;'time&#8217;})<br />
  error(&#8230;)<br />
end</p>
<p>jiro</p>
]]></content:encoded>
	</item>
</channel>
</rss>

