How to solve "Not Enough Input Arguments" error in a recursive function?
显示 更早的评论
The goal of my program is to create Sierpinski Carpet. When i run the code i get the "Not Enough Input Arguments" error.
function out= MyFunction(x, y ,width, depth, max_depth)
clc
if depth > max_depth
rectangle('Position',[x, y, width, width]);
else
width=width/3;
MyFunction(x, y, width, depth+1);
MyFunction(x+width, y, width, depth+1);
MyFunction(x+width+width, y, width, depth+1);
MyFunction(x, y+width, width, depth+1);
%MyFunction(x, y+width, width, depth+1); %middle empty
MyFunction(x+width+width, y+width, width, depth+1);
MyFunction(x, y+width+width, width, depth+1);
MyFunction(x+width, y+width+width, width, depth+1);
MyFunction(x+width+width, y+width+width, width, depth+1);
end
end
When i call the function in console i get the error for example:
> MyFunction(0,0,9,0,3)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Polygons 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!