Borrar filtros
Borrar filtros

Function Output?

5 visualizaciones (últimos 30 días)
Steve
Steve el 16 de Oct. de 2011
Hello Experts,
Consider I have
function res = test(c)
if c>0
res=1;
else
break;
end
end
I want function test to print nothing if c<0. How can I do it?
Thanks a lot!

Respuestas (1)

Wayne King
Wayne King el 16 de Oct. de 2011
Do you want something like this:
function res = test(c)
if c>=0
res=1;
else
error('Input must be nonnegative');
end
end
If you just want res to be empty, you can do:
function res = test(c)
if c>0
res=1;
else
res = [];
end
end

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by