필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

convert to recursion maintaining one input

조회 수: 1 (최근 30일)
amateurintraining
amateurintraining 2017년 10월 20일
마감: MATLAB Answer Bot 2021년 8월 20일
I have a function:
function [ filled ] = travelDistance( blank )
filled=helper(blank);
function filled = helper(f,x,y)
filled=blank;
[a,b]=size(blank);
if(y<=b)
filled=travelDistance(f,x,y+1);
elseif (x<=a)
filled=travelDistance(f,x+1,2);
elseif (f<=1000)
filled=travelDistance(f+1,2,2);
end
filled(x,y);
if filled(x,y)==0
if (filled(x-1,y)==f||filled(x,y-1)==f||filled(x,y+1)==f)
filled(x,y)=f+1;
end
else
filled(x,y);
end
end
end
in which I have attempted to create a recursion function. However, when testing, I get an error:
not enough input arguments
How to I create the recursion function, keeping the input "blank"?

답변 (1개)

bdlawr
bdlawr 2017년 10월 20일
instead of
filled=travelDistance(f,x,y+1);
do you mean helper(f,x,y+1)?
  댓글 수: 4
amateurintraining
amateurintraining 2017년 10월 20일
Yeah, I'm still stuck. If you do find out, please let me know!
bdlawr
bdlawr 2017년 10월 26일
would you like to collaborate and help each other?

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by