How to solve "Not Enough Input Arguments" error in a recursive function?
Show older comments
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)
Accepted Answer
More Answers (0)
Categories
Find more on Polygons in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!