How to make a recursive call to a function using output values stored in a array?
이전 댓글 표시
I have a matlab code for mobius function which gives output for the entered single n value. Now, I want make these functions to be called again for array of numbers to make further operations. Here is my code
function mobius (n)
n=input('Enter n');
j=0;
p = factor(n);
N = hist([0 p],max(p)+1);
r = sum(N(2:end) > 1);
disp('The mobius value of'), disp(n), disp('is');
if (n == 1)
u = 1;
elseif (r > 0)
u = 0;
else
k = sum(N(2:end) > 0);
u = (-1)^k;
end
a=[ 4 5 6 8 20];
x=mobius(a(i))+mobius(a(j));
disp(x);
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!