How to find the firs numeric data in varargin?
1 view (last 30 days)
Show older comments
How to find the firs numeric data in varargin?
0 Comments
Accepted Answer
Kirby Fears
on 16 Sep 2015
If the below code is not the answer you want, please elaborate on your question.
function MrM(varargin)
firstnum=find(cellfun(@(s)isnumeric(s),varargin),1,'first');
disp(firstnum);
end
2 Comments
Kirby Fears
on 16 Sep 2015
Then firstnum is empty. You can use
isempty(firstnum)
to know if numerical input was provided or not. You can use error handling like
if isempty(firstnum),
error('MrM() requires at least one numerical input');
end
Hope this helps.
More Answers (0)
See Also
Categories
Find more on MATLAB Compiler SDK in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!