<?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: General-use object copy	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/general-use-object-copy/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/general-use-object-copy?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=general-use-object-copy</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Wed, 16 Aug 2017 10:44:38 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Mario Koddenbrock		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-412009</link>

		<dc:creator><![CDATA[Mario Koddenbrock]]></dc:creator>
		<pubDate>Wed, 16 Aug 2017 10:44:38 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-412009</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/general-use-object-copy#comment-412002&quot;&gt;Mario Koddenbrock&lt;/a&gt;.

Thanks for your fast reply @Yair.

I’m really just trying to copy an object inside my workspace. There is no file IO involved…]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/general-use-object-copy#comment-412002">Mario Koddenbrock</a>.</p>
<p>Thanks for your fast reply @Yair.</p>
<p>I’m really just trying to copy an object inside my workspace. There is no file IO involved…</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-412003</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 16 Aug 2017 09:45:51 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-412003</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/general-use-object-copy#comment-412002&quot;&gt;Mario Koddenbrock&lt;/a&gt;.

@Mario - I suspect that you are trying to move data between different computer types and/or different Matlab releases, and this is apparently not supported.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/general-use-object-copy#comment-412002">Mario Koddenbrock</a>.</p>
<p>@Mario &#8211; I suspect that you are trying to move data between different computer types and/or different Matlab releases, and this is apparently not supported.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Mario Koddenbrock		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-412002</link>

		<dc:creator><![CDATA[Mario Koddenbrock]]></dc:creator>
		<pubDate>Wed, 16 Aug 2017 09:41:12 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-412002</guid>

					<description><![CDATA[Hi Yair,

from time to time I get the following error: 

&lt;pre lang=&quot;matlab&quot;&gt;
&quot;Error using getArrayFromByteStream
Unable to read data stream because the data contains a bad version or endian-key&quot;
&lt;/pre&gt;

It seems not to be reproducable.
Do you know reasons or fixes for that?

Best regards,
Mario]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,</p>
<p>from time to time I get the following error: </p>
<pre lang="matlab">
"Error using getArrayFromByteStream
Unable to read data stream because the data contains a bad version or endian-key"
</pre>
<p>It seems not to be reproducable.<br />
Do you know reasons or fixes for that?</p>
<p>Best regards,<br />
Mario</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-409935</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sat, 08 Jul 2017 17:53:34 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-409935</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348884&quot;&gt;Bill&lt;/a&gt;.

@Scott - nice idea!
Thanks for sharing]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348884">Bill</a>.</p>
<p>@Scott &#8211; nice idea!<br />
Thanks for sharing</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Scott Koch		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-409881</link>

		<dc:creator><![CDATA[Scott Koch]]></dc:creator>
		<pubDate>Fri, 07 Jul 2017 18:15:43 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-409881</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348884&quot;&gt;Bill&lt;/a&gt;.

Hi Bill – You might try creating a simple wrapper class to hold your old object. It&#039;s a little hacky but seemed to work for me.


&lt;pre lang=&quot;matlab&quot;&gt;
classdef wrapper
   properties
      oldobj
   end
end
&lt;/pre&gt;

Then use the property to store your old object:

&lt;pre lang=&quot;matlab&quot;&gt;
a = wrapper;
a.oldobj = oldobject;
b = getByteStreamFromArray(a);
c = getArrayFromByteStream(b);
c.oldobj
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348884">Bill</a>.</p>
<p>Hi Bill – You might try creating a simple wrapper class to hold your old object. It&#8217;s a little hacky but seemed to work for me.</p>
<pre lang="matlab">
classdef wrapper
   properties
      oldobj
   end
end
</pre>
<p>Then use the property to store your old object:</p>
<pre lang="matlab">
a = wrapper;
a.oldobj = oldobject;
b = getByteStreamFromArray(a);
c = getArrayFromByteStream(b);
c.oldobj
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-351430</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 16 Jun 2015 18:05:16 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-351430</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/general-use-object-copy#comment-351429&quot;&gt;Balint&lt;/a&gt;.

@Balint - You could perhaps create a new user class that inherits from &lt;i&gt;&lt;b&gt;container.Map&lt;/b&gt;&lt;/i&gt;. However, &lt;i&gt;&lt;b&gt;container.Map&lt;/b&gt;&lt;/i&gt; also has poor performance compared to &lt;code&gt;java.util.Hashtable&lt;/code&gt; (for example). So my advise is to implement your own user class based on an underlying Java object, using serialization/deserialization (as shown in the article above) as needed to store the Matlab objects in the Java object.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/general-use-object-copy#comment-351429">Balint</a>.</p>
<p>@Balint &#8211; You could perhaps create a new user class that inherits from <i><b>container.Map</b></i>. However, <i><b>container.Map</b></i> also has poor performance compared to <code>java.util.Hashtable</code> (for example). So my advise is to implement your own user class based on an underlying Java object, using serialization/deserialization (as shown in the article above) as needed to store the Matlab objects in the Java object.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Balint		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-351429</link>

		<dc:creator><![CDATA[Balint]]></dc:creator>
		<pubDate>Tue, 16 Jun 2015 17:57:06 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-351429</guid>

					<description><![CDATA[I am trying to fix containers.Map&#039;s crazy choice of handle semantics by wrapping it into some auto-copy class.

So far it appears that both this approach, and the matlab.mixin.Copyable facility requires an explicit call to the copy() method to actually do something. copy() is not called for an A = B call if A inherits from it. Thus to name Copyable as a copy constructor equivalent is a bit of a joke I think, as the copy constructor&#039;s most important feature is that it gets called automatically whenever a new object is created from another object. 

Am I missing something here? If not, do you have an idea how could I make containers.Map to follow value semantics, apart from reimplementing it completely in a custom variant?]]></description>
			<content:encoded><![CDATA[<p>I am trying to fix containers.Map&#8217;s crazy choice of handle semantics by wrapping it into some auto-copy class.</p>
<p>So far it appears that both this approach, and the matlab.mixin.Copyable facility requires an explicit call to the copy() method to actually do something. copy() is not called for an A = B call if A inherits from it. Thus to name Copyable as a copy constructor equivalent is a bit of a joke I think, as the copy constructor&#8217;s most important feature is that it gets called automatically whenever a new object is created from another object. </p>
<p>Am I missing something here? If not, do you have an idea how could I make containers.Map to follow value semantics, apart from reimplementing it completely in a custom variant?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348930</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 07 May 2015 09:58:44 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-348930</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348922&quot;&gt;Martin&lt;/a&gt;.

@Martin - 

&#160;&#160;&#160;&#160;&lt;i&gt;&quot;the relationship between load/getArrayFromByteStream and save/getByteStreamFromArray is a bit more complicated than just one using the other. But they both rely on some common internal infrastructure.&quot;&lt;/i&gt;

I assume you mean they all use &lt;i&gt;&lt;b&gt;&lt;a href=&quot;http://undocumentedmatlab.com/blog/serializing-deserializing-matlab-data#MEX&quot; rel=&quot;nofollow&quot;&gt;mxSerialize/mxDeserialize&lt;/a&gt;&lt;/b&gt;&lt;/i&gt; under the hood. That would be pretty close...]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348922">Martin</a>.</p>
<p>@Martin &#8211; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#8220;the relationship between load/getArrayFromByteStream and save/getByteStreamFromArray is a bit more complicated than just one using the other. But they both rely on some common internal infrastructure.&#8221;</i></p>
<p>I assume you mean they all use <i><b><a href="http://undocumentedmatlab.com/blog/serializing-deserializing-matlab-data#MEX" rel="nofollow">mxSerialize/mxDeserialize</a></b></i> under the hood. That would be pretty close&#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Martin		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348922</link>

		<dc:creator><![CDATA[Martin]]></dc:creator>
		<pubDate>Thu, 07 May 2015 06:46:04 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-348922</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348886&quot;&gt;Sam Roberts&lt;/a&gt;.

@Yair – To my knowledge, the relationship between &lt;em&gt;load&lt;/em&gt;/&lt;em&gt;getArrayFromByteStream&lt;/em&gt; and &lt;em&gt;save&lt;/em&gt;/&lt;em&gt;getByteStreamFromArray&lt;/em&gt; is a bit more complicated than just one using the other. But they both rely on some common internal infrastructure.

The best way to see the similarity is to compare the bytes coming out of &lt;em&gt;getByteStreamFromArray(data)&lt;/em&gt; and &lt;em&gt;save(filename, &#039;data&#039;, &#039;-v6&#039;)&lt;/em&gt;. The latter has a header that the former doesn&#039;t have, but this is not the only difference …]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348886">Sam Roberts</a>.</p>
<p>@Yair – To my knowledge, the relationship between <em>load</em>/<em>getArrayFromByteStream</em> and <em>save</em>/<em>getByteStreamFromArray</em> is a bit more complicated than just one using the other. But they both rely on some common internal infrastructure.</p>
<p>The best way to see the similarity is to compare the bytes coming out of <em>getByteStreamFromArray(data)</em> and <em>save(filename, &#8216;data&#8217;, &#8216;-v6&#8217;)</em>. The latter has a header that the former doesn&#8217;t have, but this is not the only difference …</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Bill		</title>
		<link>https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348898</link>

		<dc:creator><![CDATA[Bill]]></dc:creator>
		<pubDate>Wed, 06 May 2015 21:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5782#comment-348898</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348885&quot;&gt;Yair Altman&lt;/a&gt;.

The old-style non-classdef classes I&#039;m using do have default constructors.  For example the simple test class below give the same error:

@foo/foo.m
&lt;pre lang=&#039;matlab&#039;&gt;
function [obj] = foo(varargin)
obj = class(struct(&#039;x&#039;,1), &#039;foo&#039;);
&lt;/pre&gt;

&lt;pre lang=&#039;matlab&#039;&gt;
&gt;&gt; getArrayFromByteStream(getByteStreamFromArray(foo))
Temporary object of class :all: is missing a constructor or an error occurred
in calling constructor with no inputs.
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/general-use-object-copy#comment-348885">Yair Altman</a>.</p>
<p>The old-style non-classdef classes I&#8217;m using do have default constructors.  For example the simple test class below give the same error:</p>
<p>@foo/foo.m</p>
<pre lang='matlab'>
function [obj] = foo(varargin)
obj = class(struct('x',1), 'foo');
</pre>
<pre lang='matlab'>
>> getArrayFromByteStream(getByteStreamFromArray(foo))
Temporary object of class :all: is missing a constructor or an error occurred
in calling constructor with no inputs.
</pre>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
