Need to define function over two ranges of input

I have a function dependent on one input n I want the function to perform one operation for n=0, and another for n>=1 How can I do this? I'm sure this answer has already been answered elsewhere, however I am unable to find it, so if you can even link a preexisting solution online, that would be perfect. Thanks

 채택된 답변

Image Analyst
Image Analyst 2016년 2월 2일

0 개 추천

Try this:
function output = AssignOutput(n)
if n == 0
output = whatever....
elseif n >= 1
output = somethingElse.......
else
output = someErrorValue perhaps....
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2016년 2월 2일

댓글:

2016년 2월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by