ERROR - Error using zajimava_uloha (line 7) Not enough input arguments. Why?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
function pravd = zajimava_uloha(n)
% pravd = zajimava_uloha(n)
%
% vypocte pravdepodobnost toho, ze kdyz nahodne zamichate prirozena
% cisla 1 az n, nezustane ani jedno cislo na sve puvodni pozici
if n <= 0 , n - floor(n) > eps
error('n neni prirozene cislo')
end
perm = permutace(n); % generuje vsechna mozna usporadani n cisel
pocet_perm=size(perm,1); % pocet vsech moznych usporadani n cisel
for i=1:pocet_perm
pom(i,:)=[1:n];
end
P=(pom==perm);
pom2=sum(P,2);
pom2=~pom2;
suma=sum(pom2); % pocet vsech usporadani, u kterych neni ani jedno cislo na svem puvodnim miste
pravd=suma/pocet_perm;
disp(['Pravdepodobnost: ', num2str(pravd)])
% konec
댓글 수: 1
Daniel Shub
2012년 4월 9일
Please format the code properly. If you could point out line 7 that would also be help. Finally provide the entire error stack.
답변 (1개)
Sean de Wolski
2012년 4월 9일
How are you calling zajimava_uloha? If you are just using the green "play" button, n the lone input argument will be undefined and you will see this error.
To run this function properly, call it with one input argument, maybe:
zajimava_uloha(pi)
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!