convert to recursion maintaining one input

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 日

0 投票

instead of
filled=travelDistance(f,x,y+1);
do you mean helper(f,x,y+1)?

4 件のコメント

amateurintraining
amateurintraining 2017 年 10 月 20 日
I did make that mistake and have corrected it. However, I still get an error:
index exceeds matrix dimensions
bdlawr
bdlawr 2017 年 10 月 20 日
darn. have you gotten any progress on it? i've stuck on this problem for a while now too...it would be great if you can help me out if you got it. will be happy to share if i got the problem down
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?

この質問は閉じられています。

質問済み:

2017 年 10 月 20 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by