??? Attempted to access l(0); index must be a positive integer or logical.

hi, all. i have a little problem here i use this code:
function y=iseng(x,d,n)
l=dec2bin(d);
k=length(l);
y=1;
for j=(k-1):-1:0
y= y*mod(y,n);
if l(j) == 1
y= y*mod(x,n);
end
end
but every-time i use that function it's return error: ??? Attempted to access l(0); index must be a positive integer or logical. Error in ==> iseng at 8 if l(j) == 1
anyone know my mistake??

 채택된 답변

Sean de Wolski
Sean de Wolski 2011년 6월 24일

1 개 추천

L(0) doesn't exist since MATLAB doesn't use zero-based indexing. You can only go to L(1)

추가 답변 (1개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by