How to check a function input to be ptcloud object?

조회 수: 3 (최근 30일)
Philipp Schnabel
Philipp Schnabel 2019년 6월 4일
댓글: Philipp Schnabel 2019년 6월 4일
Hello,
I want to right some functions, which will have the matlab ptCloud objects as inputs. I want to validate the inputs at the beginn of the function, I know I can use inputParser to do that, but it looks like it doesn't like the object as an input at all.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2019년 6월 4일
Hi Philipp,
probably you are looking for the function "isa":
function myfun(x)
if ~isa(x, 'ptCloud')
error('Input argument x must be ptCloud object')
end
Titus
  댓글 수: 1
Philipp Schnabel
Philipp Schnabel 2019년 6월 4일
Thank you Titus,
it did help really, now I have one more question, how can i check that the PointCloud Object is not empty? Can I access the data inside and check it in the InputParser? My code example does look like this:
function [tform, cov, error, time] = test(move,fix,iter,varargin)
inp = inputParser;
inp.addRequired('move', @(x) isa(x, 'pointCloud'));
inp.addRequired('fix', @(x) isa(x, 'pointCloud'));
inp.addOptional('iter', 10, @(x)x > 0 && x < 10^5);
inp.parse(move,fix,iter,varargin{:});
tform = affine3d();
cov = zeros(6);
error = 0;
time = 0;

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by