Array element containing infinity

조회 수: 2 (최근 30일)
lilly lord
lilly lord 2020년 11월 17일
댓글: Adam Danz 2020년 11월 17일
Hi. I have a problem in array indexing containing infinity.
I have to compute the function f(a)=1-1/a mod 13 . It takes values from [infinity 0,1,2 ...12] and out put should be [1,inf,0,7,5,4,6,3,12,9,11,10,8 and 2]
I have tried to code it but it gives error at infinity.
Y_trans=[];
p=[];
n=13;
P_2=[];
y_axis=[];
for i=1:13
if modInv(i,n)==0
P_2(i)=Inf
else
P_2(i)=modInv(i,n);
[Y_trans(i)]= mod(1-P_2(i),n);
end
end
  댓글 수: 6
lilly lord
lilly lord 2020년 11월 17일
I want the out put as [1,inf,0,7,5,4,6,3,12,9,11,10,8 and 2]
When I start i from 0 to 12, it gives an error
"Array indices must be positive integers or logical values".
Adam Danz
Adam Danz 2020년 11월 17일
" please share the entire error message", all of it, and let us know which line is throwing the error.
The only indices I see are i and n and both are positive integers.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by