Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!y42g2000hsy.googlegroups.com!not-for-mail
From:  "G.A.M." <x0Zero@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: inputParser not validating serial object correctly
Date: Sun, 23 Sep 2007 01:42:44 -0000
Organization: http://groups.google.com
Lines: 30
Message-ID: <1190511764.536671.125930@y42g2000hsy.googlegroups.com>
NNTP-Posting-Host: 24.129.101.179
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1190511764 15023 127.0.0.1 (23 Sep 2007 01:42:44 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 23 Sep 2007 01:42:44 +0000 (UTC)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: y42g2000hsy.googlegroups.com; posting-host=24.129.101.179;
Xref: news.mathworks.com comp.soft-sys.matlab:429757



My error msg is:
Argument 'serialPort' failed validation @(sp)isa(sp,'serial').

My code is:

function status = DoSomethingWithSerialPort(serialPort, varargin)

	p = inputParser;
	p.addRequired('serialPort', @(sp)isa(sp, 'serial'));
	p.addParamValue('test','', @ischar);
	p.parse('serialPort', varargin{:});
	test= p.Results.test;
       %etc.

After getting the error, I checked the class of the function
parameter, and it was as expected:
class(serialPort)
ans = serial

Then, to continue debugging, I created this anonymous function in the
workspace:
x = @(sp)isa(sp, 'serial')

I used it to check the input parameter and it was again as expected:
x(serialPort)
ans =      1

So does anyone have any idea why I get the error shown at the top?
Thanks.