<?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: Solving a MATLAB bug by subclassing	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=solving-a-matlab-bug-by-subclassing</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Fri, 03 Feb 2012 11:51:43 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing#comment-73117</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Fri, 03 Feb 2012 11:51:43 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1110#comment-73117</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing#comment-73116&quot;&gt;sumaia&lt;/a&gt;.

@sumaia - &lt;b&gt;&lt;i&gt;validateattributes&lt;/i&gt;&lt;/b&gt; simply ensures that the specified input variable is of the expected type. You can make these checks yourself, without really needing to use &lt;b&gt;&lt;i&gt;validateattributes&lt;/i&gt;&lt;/b&gt;. Or, if you are confident that the variables are of the expected type, you can skip these checks altogether.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing#comment-73116">sumaia</a>.</p>
<p>@sumaia &#8211; <b><i>validateattributes</i></b> simply ensures that the specified input variable is of the expected type. You can make these checks yourself, without really needing to use <b><i>validateattributes</i></b>. Or, if you are confident that the variables are of the expected type, you can skip these checks altogether.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sumaia		</title>
		<link>https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing#comment-73116</link>

		<dc:creator><![CDATA[sumaia]]></dc:creator>
		<pubDate>Fri, 03 Feb 2012 11:27:43 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1110#comment-73116</guid>

					<description><![CDATA[I am trying to run an example that uses validateattributes. My matlab is an older version and doesn&#039;t recognise this function.  Is it possible to load this function to my matlab and if so can you tell me how.  I also need the function list.
Many thanks]]></description>
			<content:encoded><![CDATA[<p>I am trying to run an example that uses validateattributes. My matlab is an older version and doesn&#8217;t recognise this function.  Is it possible to load this function to my matlab and if so can you tell me how.  I also need the function list.<br />
Many thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Matt Whitaker		</title>
		<link>https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing#comment-8005</link>

		<dc:creator><![CDATA[Matt Whitaker]]></dc:creator>
		<pubDate>Tue, 09 Mar 2010 19:54:48 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1110#comment-8005</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing#comment-7843&quot;&gt;Foster&lt;/a&gt;.

Hi Foster,
This is another good situation for subclassing.
Here is a pretty minimal class for setting the vertex size. Note it does not handle the situation of adding a new vertex or changing vertex color after creation. For now you can just call the setVertexSize method after doing one of those operations. That&#039;s slightly more sophisticated and may be worth a complete blog entry.

&lt;pre lang=&quot;matlab&quot;&gt;
classdef impoly_vertex &lt; impoly
    
    properties (GetAccess = public, SetAccess = private)
        vertexCrossSize;
        vertexDotSize;
    end %properties
    
    methods
        function obj =  impoly_vertex(crossSize,dotSize,varargin)
            if nargin &lt; 2
                error(&#039;impoly_vertex:InsufficientArguments&#039;,&#039;Both the cross and dot size must be passed as constructor arguments&#039;);
            end %if
            obj = obj@impoly(varargin{:});
            obj.parseSizeInputs(crossSize,dotSize);
            obj.setVertexSize;
        end %impoly_vertex
        
        function setVertexSize(obj)
            crossChildren = findobj(obj.h_group,&#039;Type&#039;,&#039;line&#039;,&#039;Marker&#039;,&#039;+&#039;);
            dotChildren = findobj(obj.h_group,&#039;Type&#039;,&#039;line&#039;,&#039;Marker&#039;,&#039;O&#039;);
            set(crossChildren,&#039;MarkerSize&#039;,obj.vertexCrossSize);
            set(dotChildren,&#039;MarkerSize&#039;,obj.vertexDotSize);
        end
        
        function setCrossSize(obj,cs)
            obj.parseSizeInputs(cs,obj.vertexDotSize);
            obj.setVertexSize;
        end %setCrossSize
        
        function setDotSize(obj,ds)
            obj.parseSizeInputs(obj.vertexCrossSize,ds);
            obj.setVertexSize;
        end %setCrossSize
    end
    
    methods (Access = protected)
        function parseSizeInputs(obj,cs,ds)
            validateattributes(cs,{&#039;numeric&#039;},{&#039;scalar&#039;,&#039;nonnegative&#039;,&#039;real&#039;});
            validateattributes(ds,{&#039;numeric&#039;},{&#039;scalar&#039;,&#039;nonnegative&#039;,&#039;real&#039;});
            obj.vertexCrossSize = cs;
            obj.vertexDotSize = ds;
        end %parseSizeInputs
    end %private Methods    
    
end %impoly_vertex
&lt;/pre&gt;

Here we let it draw the polygon then find the vertices and change the marker size of the lines that make them up. Usage as follows:

&lt;pre lang=&quot;matlab&quot;&gt;
figure, imshow(&#039;gantrycrane.png&#039;);
%about half the regular vertex size
h = impoly_vertex(4.5,2.25,gca, [188,30; 189,142; 93,141; 13,41; 14,29]);
setColor(h,&#039;yellow&#039;);
h.setVertexSize; %need to reset manually for this version
addNewPositionCallback(h,@(p) title(mat2str(p,3)));
fcn = makeConstrainToRectFcn(&#039;impoly&#039;,get(gca,&#039;XLim&#039;),...
get(gca,&#039;YLim&#039;));
setPositionConstraintFcn(h,fcn);
&lt;/pre&gt;

A couple more points:

I really try to avoid editing any of the supplied code as it becomes a maintenance headache when you change versions.

Also a useful detective tool is the metaclass class

So mc = ?impoly gives you all sorts of useful info to help design you subclass.

Hope this Helps
Matt W]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing#comment-7843">Foster</a>.</p>
<p>Hi Foster,<br />
This is another good situation for subclassing.<br />
Here is a pretty minimal class for setting the vertex size. Note it does not handle the situation of adding a new vertex or changing vertex color after creation. For now you can just call the setVertexSize method after doing one of those operations. That&#8217;s slightly more sophisticated and may be worth a complete blog entry.</p>
<pre lang="matlab">
classdef impoly_vertex < impoly
    
    properties (GetAccess = public, SetAccess = private)
        vertexCrossSize;
        vertexDotSize;
    end %properties
    
    methods
        function obj =  impoly_vertex(crossSize,dotSize,varargin)
            if nargin < 2
                error('impoly_vertex:InsufficientArguments','Both the cross and dot size must be passed as constructor arguments');
            end %if
            obj = obj@impoly(varargin{:});
            obj.parseSizeInputs(crossSize,dotSize);
            obj.setVertexSize;
        end %impoly_vertex
        
        function setVertexSize(obj)
            crossChildren = findobj(obj.h_group,'Type','line','Marker','+');
            dotChildren = findobj(obj.h_group,'Type','line','Marker','O');
            set(crossChildren,'MarkerSize',obj.vertexCrossSize);
            set(dotChildren,'MarkerSize',obj.vertexDotSize);
        end
        
        function setCrossSize(obj,cs)
            obj.parseSizeInputs(cs,obj.vertexDotSize);
            obj.setVertexSize;
        end %setCrossSize
        
        function setDotSize(obj,ds)
            obj.parseSizeInputs(obj.vertexCrossSize,ds);
            obj.setVertexSize;
        end %setCrossSize
    end
    
    methods (Access = protected)
        function parseSizeInputs(obj,cs,ds)
            validateattributes(cs,{'numeric'},{'scalar','nonnegative','real'});
            validateattributes(ds,{'numeric'},{'scalar','nonnegative','real'});
            obj.vertexCrossSize = cs;
            obj.vertexDotSize = ds;
        end %parseSizeInputs
    end %private Methods    
    
end %impoly_vertex
</pre>
<p>Here we let it draw the polygon then find the vertices and change the marker size of the lines that make them up. Usage as follows:</p>
<pre lang="matlab">
figure, imshow('gantrycrane.png');
%about half the regular vertex size
h = impoly_vertex(4.5,2.25,gca, [188,30; 189,142; 93,141; 13,41; 14,29]);
setColor(h,'yellow');
h.setVertexSize; %need to reset manually for this version
addNewPositionCallback(h,@(p) title(mat2str(p,3)));
fcn = makeConstrainToRectFcn('impoly',get(gca,'XLim'),...
get(gca,'YLim'));
setPositionConstraintFcn(h,fcn);
</pre>
<p>A couple more points:</p>
<p>I really try to avoid editing any of the supplied code as it becomes a maintenance headache when you change versions.</p>
<p>Also a useful detective tool is the metaclass class</p>
<p>So mc = ?impoly gives you all sorts of useful info to help design you subclass.</p>
<p>Hope this Helps<br />
Matt W</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Foster		</title>
		<link>https://undocumentedmatlab.com/articles/solving-a-matlab-bug-by-subclassing#comment-7843</link>

		<dc:creator><![CDATA[Foster]]></dc:creator>
		<pubDate>Thu, 04 Mar 2010 14:13:45 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1110#comment-7843</guid>

					<description><![CDATA[Good post, looking forward to more IPT-related posts in the future. 
I&#039;m new to this &#039;detective work&#039; and have a quick q.. I&#039;m using the impoly function, and trying to make the vertices smaller. I made the lines thinner by editing the (undocumented) polygonSymbol, but I can&#039;t find the bit to change the points...keep getting dead ends. I&#039;ve figured it uses impoint but I&#039;m stuck on accessing the handle objects. Any *ahem* pointers?]]></description>
			<content:encoded><![CDATA[<p>Good post, looking forward to more IPT-related posts in the future.<br />
I&#8217;m new to this &#8216;detective work&#8217; and have a quick q.. I&#8217;m using the impoly function, and trying to make the vertices smaller. I made the lines thinner by editing the (undocumented) polygonSymbol, but I can&#8217;t find the bit to change the points&#8230;keep getting dead ends. I&#8217;ve figured it uses impoint but I&#8217;m stuck on accessing the handle objects. Any *ahem* pointers?</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
