+ 1
Please may i know why is my function not working in matlab
function[count] = towers(n, frompeg, topeg, auxpeg) count=0 if (n == 1) count=count+1; fprintf('\t move disk 1 from peg %c to peg %c \n', frompeg, topeg); else towers(n-1,frompeg,auxpeg,topeg); fprintf('\t move disk %d from peg %c to peg %c \n',n,frompeg,topeg); towers(n-1,auxpeg,topeg,frompeg); end end
1 Réponse
+ 1
Check if the file name is the same as the function name
"towers.m"