complex numbers

조회 수: 14 (최근 30일)
christopher
christopher 2011년 5월 19일
Hello,
Iam trying to write a code in shannon fano coding, the M is for representing the probability.This code line is giving me error.So hw do i rectify the error, many thanks. M=zeros(len,len) M=M-1 if (M(j,i)==0|M(j,i)==1)
??? Subscript indices must either be real positive integers or logicals.
Error in ==> p_main at 14 if (M(j,i)==0|M(j,i)==1)

답변 (2개)

Arnaud Miege
Arnaud Miege 2011년 5월 19일
You probably want:
if (M(j,i)==0 || M(i,j)==1)
However, I would not recommend testing directly for equality if you're using double data types. Here's why:
Instead compare the abs of the difference to some small tolerance value.
HTH,
Arnaud
  댓글 수: 1
Arnaud Miege
Arnaud Miege 2011년 5월 19일
As Daniel pointed out, it's also likely that your indices i and j are out of bounds. It would help if you posted the code.

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


Daniel Shub
Daniel Shub 2011년 5월 19일
??? Subscript indices must either be real positive integers or logicals.
means that i or j (your subscripts of M) is not a real positive integer. Many MATLAB users avoid using i and j as counters since they initialize as sqrt(-1). It is also possible that when you set i or j, you set it to 0.

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by