<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156591</link>
    <title>MATLAB Central Newsreader - inputParser not validating serial object correctly</title>
    <description>Feed for thread: inputParser not validating serial object correctly</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 23 Sep 2007 01:42:44 -0400</pubDate>
      <title>inputParser not validating serial object correctly</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156591#393537</link>
      <author> &quot;G.A.M.</author>
      <description>My error msg is:&lt;br&gt;
Argument 'serialPort' failed validation @(sp)isa(sp,'serial').&lt;br&gt;
&lt;br&gt;
My code is:&lt;br&gt;
&lt;br&gt;
function status = DoSomethingWithSerialPort(serialPort, varargin)&lt;br&gt;
&lt;br&gt;
	p = inputParser;&lt;br&gt;
	p.addRequired('serialPort', @(sp)isa(sp, 'serial'));&lt;br&gt;
	p.addParamValue('test','', @ischar);&lt;br&gt;
	p.parse('serialPort', varargin{:});&lt;br&gt;
	test= p.Results.test;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%etc.&lt;br&gt;
&lt;br&gt;
After getting the error, I checked the class of the function&lt;br&gt;
parameter, and it was as expected:&lt;br&gt;
class(serialPort)&lt;br&gt;
ans = serial&lt;br&gt;
&lt;br&gt;
Then, to continue debugging, I created this anonymous function in the&lt;br&gt;
workspace:&lt;br&gt;
x = @(sp)isa(sp, 'serial')&lt;br&gt;
&lt;br&gt;
I used it to check the input parameter and it was again as expected:&lt;br&gt;
x(serialPort)&lt;br&gt;
ans =      1&lt;br&gt;
&lt;br&gt;
So does anyone have any idea why I get the error shown at the top?&lt;br&gt;
Thanks.</description>
    </item>
    <item>
      <pubDate>Mon, 24 Sep 2007 14:08:17 -0400</pubDate>
      <title>Re: inputParser not validating serial object correctly</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156591#393687</link>
      <author>Philip Borghesani</author>
      <description>You have the inputs to parse wrong try:&lt;br&gt;
p.parse(varargin{:});&lt;br&gt;
or&lt;br&gt;
parse(p,varargin{:})&lt;br&gt;
&lt;br&gt;
Phil&lt;br&gt;
&lt;br&gt;
&quot;G.A.M.&quot; &amp;lt;x0Zero@gmail.com&amp;gt; wrote in message news:1190511764.536671.125930@y42g2000hsy.googlegroups.com...&lt;br&gt;
&amp;gt; My error msg is:&lt;br&gt;
&amp;gt; Argument 'serialPort' failed validation @(sp)isa(sp,'serial').&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; My code is:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; function status = DoSomethingWithSerialPort(serialPort, varargin)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; p = inputParser;&lt;br&gt;
&amp;gt; p.addRequired('serialPort', @(sp)isa(sp, 'serial'));&lt;br&gt;
&amp;gt; p.addParamValue('test','', @ischar);&lt;br&gt;
&amp;gt; p.parse('serialPort', varargin{:});&lt;br&gt;
&amp;gt; test= p.Results.test;&lt;br&gt;
&amp;gt;       %etc.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; After getting the error, I checked the class of the function&lt;br&gt;
&amp;gt; parameter, and it was as expected:&lt;br&gt;
&amp;gt; class(serialPort)&lt;br&gt;
&amp;gt; ans = serial&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Then, to continue debugging, I created this anonymous function in the&lt;br&gt;
&amp;gt; workspace:&lt;br&gt;
&amp;gt; x = @(sp)isa(sp, 'serial')&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I used it to check the input parameter and it was again as expected:&lt;br&gt;
&amp;gt; x(serialPort)&lt;br&gt;
&amp;gt; ans =      1&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; So does anyone have any idea why I get the error shown at the top?&lt;br&gt;
&amp;gt; Thanks.&lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Tue, 25 Sep 2007 15:55:02 -0400</pubDate>
      <title>Is Matlab Help incorrect Re: inputParser  (parser is not validating serial object correctly)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156591#393878</link>
      <author> &quot;G.A.M.</author>
      <description>&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &quot;G.A.M.&quot; &amp;lt;x0Z...@gmail.com&amp;gt; wrote in messagenews:1190511764.536671.125930@y42g2000hsy.googlegroups.com...&lt;br&gt;
&amp;gt; &amp;gt; My error msg is:&lt;br&gt;
&amp;gt; &amp;gt; Argument 'serialPort' failed validation @(sp)isa(sp,'serial').&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; My code is:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; function status = DoSomethingWithSerialPort(serialPort, varargin)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; p = inputParser;&lt;br&gt;
&amp;gt; &amp;gt; p.addRequired('serialPort', @(sp)isa(sp, 'serial'));&lt;br&gt;
&amp;gt; &amp;gt; p.addParamValue('test','', @ischar);&lt;br&gt;
&amp;gt; &amp;gt; p.parse('serialPort', varargin{:});&lt;br&gt;
&amp;gt; &amp;gt; test= p.Results.test;&lt;br&gt;
&amp;gt; &amp;gt;       %etc.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; After getting the error, I checked the class of the function&lt;br&gt;
&amp;gt; &amp;gt; parameter, and it was as expected:&lt;br&gt;
&amp;gt; &amp;gt; class(serialPort)&lt;br&gt;
&amp;gt; &amp;gt; ans = serial&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Then, to continue debugging, I created this anonymous function in the&lt;br&gt;
&amp;gt; &amp;gt; workspace:&lt;br&gt;
&amp;gt; &amp;gt; x = @(sp)isa(sp, 'serial')&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I used it to check the input parameter and it was again as expected:&lt;br&gt;
&amp;gt; &amp;gt; x(serialPort)&lt;br&gt;
&amp;gt; &amp;gt; ans =      1&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; So does anyone have any idea why I get the error shown at the top?&lt;br&gt;
&amp;gt; &amp;gt; Thanks.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
On Sep 24, 10:08 am, &quot;Philip Borghesani&quot;&lt;br&gt;
&amp;lt;philip_borghes...@mathworks.spam&amp;gt; wrote:&lt;br&gt;
&amp;gt; You have the inputs to parse wrong try:&lt;br&gt;
&amp;gt; p.parse(varargin{:});&lt;br&gt;
&amp;gt; or&lt;br&gt;
&amp;gt; parse(p,varargin{:})&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Phil&lt;br&gt;
&lt;br&gt;
Phil-thanks for your reply.&lt;br&gt;
Matlab help on input parser gives this example:&lt;br&gt;
&lt;br&gt;
function publish_ip(script, varargin)&lt;br&gt;
p = inputParser;&lt;br&gt;
p.addRequired('script', @ischar);&lt;br&gt;
p.addOptional(...&lt;br&gt;
[snip]&lt;br&gt;
p.parse(script, varargin{:});&lt;br&gt;
&lt;br&gt;
That's the example I'm following and I have used this style in a lot&lt;br&gt;
of places in my code where it has seemingly worked correctly.&lt;br&gt;
&lt;br&gt;
What I took from the example is that required arguments need to be&lt;br&gt;
named in the call to parse().&lt;br&gt;
&lt;br&gt;
1. Is the example code I posted originally an incorrect implementation&lt;br&gt;
of what is shown in Matlab help?&lt;br&gt;
2. Am I misunderstanding the example?&lt;br&gt;
3. Is the help example incorrect?&lt;br&gt;
&lt;br&gt;
Here's the help section I'm viewing:&lt;br&gt;
inputParser :: Functions (MATLAB Function Reference)&lt;br&gt;
help/techdoc/help.jar!/ref/inputparser.html</description>
    </item>
    <item>
      <pubDate>Tue, 02 Oct 2007 14:56:18 -0400</pubDate>
      <title>Re: Is Matlab Help incorrect Re: inputParser  (parser is not validating serial object correctly)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156591#394793</link>
      <author>G.A.M. </author>
      <description>&amp;nbsp;&quot;G.A.M.&quot; &amp;lt;x0Zero@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;1190735702.705426.76450@50g2000hsm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &quot;G.A.M.&quot; &amp;lt;x0Z...@gmail.com&amp;gt; wrote in&lt;br&gt;
messagenews:1190511764.536671.125930@y42g2000hsy.googlegroups.com...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; My error msg is:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Argument 'serialPort' failed validation&lt;br&gt;
@(sp)isa(sp,'serial').&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; My code is:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; function status =&lt;br&gt;
DoSomethingWithSerialPort(serialPort, varargin)&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; p = inputParser;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; p.addRequired('serialPort', @(sp)isa(sp, 'serial'));&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; p.addParamValue('test','', @ischar);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; p.parse('serialPort', varargin{:});&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; test= p.Results.test;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;       %etc.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; After getting the error, I checked the class of the&lt;br&gt;
function&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; parameter, and it was as expected:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; class(serialPort)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ans = serial&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Then, to continue debugging, I created this anonymous&lt;br&gt;
function in the&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; workspace:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; x = @(sp)isa(sp, 'serial')&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; I used it to check the input parameter and it was&lt;br&gt;
again as expected:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; x(serialPort)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ans =      1&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; So does anyone have any idea why I get the error shown&lt;br&gt;
at the top?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; On Sep 24, 10:08 am, &quot;Philip Borghesani&quot;&lt;br&gt;
&amp;gt; &amp;lt;philip_borghes...@mathworks.spam&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; You have the inputs to parse wrong try:&lt;br&gt;
&amp;gt; &amp;gt; p.parse(varargin{:});&lt;br&gt;
&amp;gt; &amp;gt; or&lt;br&gt;
&amp;gt; &amp;gt; parse(p,varargin{:})&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Phil&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Phil-thanks for your reply.&lt;br&gt;
&amp;gt; Matlab help on input parser gives this example:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function publish_ip(script, varargin)&lt;br&gt;
&amp;gt; p = inputParser;&lt;br&gt;
&amp;gt; p.addRequired('script', @ischar);&lt;br&gt;
&amp;gt; p.addOptional(...&lt;br&gt;
&amp;gt; [snip]&lt;br&gt;
&amp;gt; p.parse(script, varargin{:});&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; That's the example I'm following and I have used this&lt;br&gt;
style in a lot&lt;br&gt;
&amp;gt; of places in my code where it has seemingly worked correctly.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What I took from the example is that required arguments&lt;br&gt;
need to be&lt;br&gt;
&amp;gt; named in the call to parse().&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 1. Is the example code I posted originally an incorrect&lt;br&gt;
implementation&lt;br&gt;
&amp;gt; of what is shown in Matlab help?&lt;br&gt;
&amp;gt; 2. Am I misunderstanding the example?&lt;br&gt;
&amp;gt; 3. Is the help example incorrect?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Here's the help section I'm viewing:&lt;br&gt;
&amp;gt; inputParser :: Functions (MATLAB Function Reference)&lt;br&gt;
&amp;gt; help/techdoc/help.jar!/ref/inputparser.html&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I could sure use some help on this. I am continuing to&lt;br&gt;
struggle with the apparent differences in the help&lt;br&gt;
documentation for the inputParser vs. what actually works. I&lt;br&gt;
have not solved the issue I asked about in my original post&lt;br&gt;
yet. The only suggestion (to not parse the required&lt;br&gt;
arguments) doesn't seem satisfactory and it doesn't agree&lt;br&gt;
with the help docs. What am I missing? Thanks.</description>
    </item>
    <item>
      <pubDate>Tue, 02 Oct 2007 17:07:44 -0400</pubDate>
      <title>Re: inputParser not validating serial object correctly</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156591#394823</link>
      <author>per isakson</author>
      <description>&amp;nbsp;&quot;G.A.M.&quot; &amp;lt;x0Zero@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;1190511764.536671.125930@y42g2000hsy.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; My error msg is:&lt;br&gt;
&amp;gt; Argument 'serialPort' failed validation @(sp)isa&lt;br&gt;
(sp,'serial').&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; My code is:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function status = DoSomethingWithSerialPort(serialPort, &lt;br&gt;
varargin)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 	p = inputParser;&lt;br&gt;
&amp;gt; 	p.addRequired('serialPort', @(sp)isa(sp, 'serial'));&lt;br&gt;
&amp;gt; 	p.addParamValue('test','', @ischar);&lt;br&gt;
&amp;gt; 	p.parse('serialPort', varargin{:});&lt;br&gt;
&amp;gt; 	test= p.Results.test;&lt;br&gt;
&amp;gt;        %etc.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; After getting the error, I checked the class of the &lt;br&gt;
function&lt;br&gt;
&amp;gt; parameter, and it was as expected:&lt;br&gt;
&amp;gt; class(serialPort)&lt;br&gt;
&amp;gt; ans = serial&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Then, to continue debugging, I created this anonymous &lt;br&gt;
function in the&lt;br&gt;
&amp;gt; workspace:&lt;br&gt;
&amp;gt; x = @(sp)isa(sp, 'serial')&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I used it to check the input parameter and it was again &lt;br&gt;
as expected:&lt;br&gt;
&amp;gt; x(serialPort)&lt;br&gt;
&amp;gt; ans =      1&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; So does anyone have any idea why I get the error shown at &lt;br&gt;
the top?&lt;br&gt;
&amp;gt; Thanks.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
The example, publish_ip, in the documentation uses the same &lt;br&gt;
name (&quot;script&quot;) for both the name of the required variable &lt;br&gt;
and the variable itself, which is asking for mistakes. &lt;br&gt;
&lt;br&gt;
In this line &lt;br&gt;
&lt;br&gt;
p.parse( serialPort, varargin{:});&lt;br&gt;
&lt;br&gt;
&amp;lt;serialPort&amp;gt; is the name of the input variable. You have &lt;br&gt;
two blips too many.&lt;br&gt;
&lt;br&gt;
/ per&lt;br&gt;
&amp;nbsp;</description>
    </item>
    <item>
      <pubDate>Wed, 03 Oct 2007 03:02:04 -0400</pubDate>
      <title>Re: inputParser not validating serial object correctly</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156591#394879</link>
      <author> &quot;G.A.M.</author>
      <description>On Oct 2, 1:07 pm, &quot;per isakson&quot; &amp;lt;poi.nos...@bimDOTkthDOT.se&amp;gt; wrote:&lt;br&gt;
&amp;gt;  &quot;G.A.M.&quot; &amp;lt;x0Z...@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;1190511764.536671.125...@y42g2000hsy.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; My error msg is:&lt;br&gt;
&amp;gt; &amp;gt; Argument 'serialPort' failed validation @(sp)isa&lt;br&gt;
&amp;gt; (sp,'serial').&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; My code is:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; function status = DoSomethingWithSerialPort(serialPort,&lt;br&gt;
&amp;gt; varargin)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;    p = inputParser;&lt;br&gt;
&amp;gt; &amp;gt;    p.addRequired('serialPort', @(sp)isa(sp, 'serial'));&lt;br&gt;
&amp;gt; &amp;gt;    p.addParamValue('test','', @ischar);&lt;br&gt;
&amp;gt; &amp;gt;    p.parse('serialPort', varargin{:});&lt;br&gt;
&amp;gt; &amp;gt;    test= p.Results.test;&lt;br&gt;
&amp;gt; &amp;gt;        %etc.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; After getting the error, I checked the class of the&lt;br&gt;
&amp;gt; function&lt;br&gt;
&amp;gt; &amp;gt; parameter, and it was as expected:&lt;br&gt;
&amp;gt; &amp;gt; class(serialPort)&lt;br&gt;
&amp;gt; &amp;gt; ans = serial&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Then, to continue debugging, I created this anonymous&lt;br&gt;
&amp;gt; function in the&lt;br&gt;
&amp;gt; &amp;gt; workspace:&lt;br&gt;
&amp;gt; &amp;gt; x = @(sp)isa(sp, 'serial')&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I used it to check the input parameter and it was again&lt;br&gt;
&amp;gt; as expected:&lt;br&gt;
&amp;gt; &amp;gt; x(serialPort)&lt;br&gt;
&amp;gt; &amp;gt; ans =      1&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; So does anyone have any idea why I get the error shown at&lt;br&gt;
&amp;gt; the top?&lt;br&gt;
&amp;gt; &amp;gt; Thanks.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The example, publish_ip, in the documentation uses the same&lt;br&gt;
&amp;gt; name (&quot;script&quot;) for both the name of the required variable&lt;br&gt;
&amp;gt; and the variable itself, which is asking for mistakes.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; In this line&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; p.parse( serialPort, varargin{:});&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;serialPort&amp;gt; is the name of the input variable. You have&lt;br&gt;
&amp;gt; two blips too many.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; / per&lt;br&gt;
&lt;br&gt;
Thank you very much. I have looked at this example many times and I&lt;br&gt;
never noticed the fact that I had the extra blips.</description>
    </item>
  </channel>
</rss>

