필터 지우기
필터 지우기

Function Output?

조회 수: 5 (최근 30일)
Steve
Steve 2011년 10월 16일
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!

답변 (1개)

Wayne King
Wayne King 2011년 10월 16일
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

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by