How to find the firs numeric data in varargin?

 Respuesta aceptada

Kirby Fears
Kirby Fears el 16 de Sept. de 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 comentarios

Mr M.
Mr M. el 16 de Sept. de 2015
what if varargin contains no numeric value?
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Statistics and Linear Algebra en Centro de ayuda y File Exchange.

Preguntada:

el 16 de Sept. de 2015

Comentada:

el 16 de Sept. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by