How to solve "Not Enough Input Arguments" error in a recursive function?
Mostrar comentarios más antiguos
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)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Polygons en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!