Error of the following code : "Array indices must be positive integers or logical values."
조회 수: 1 (최근 30일)
이전 댓글 표시
% I have attached the file for : "ind" ; "len"; "miu".
% In the following code "line : freq(j)" I am having above mentioned error.
% Any kinds of help to solve the problem will be appreciated.
Nvar = 65536;
freq = zeros(Nvar,1);
for j = 1:Nvar
len = cell2mat(length_ijk(j));
ind = cell2mat(index_ijk(j));
freq(j) = exp(-sum(miu(ind).*len));
end
댓글 수: 0
답변 (2개)
Constantino Carlos Reyes-Aldasoro
2022년 1월 4일
Not very clear, what are length_ijk and index_ijk? in the files you have added, miu has 262144 values, ind has 77 and freq has 65536.
댓글 수: 0
Cris LaPierre
2022년 1월 4일
Not enough info to say for sure, but I suspect at some point, ind contains values that are not positive integers or logical values, causing miu(ind) to throw an error.
A = 1:3;
% works
A(2)
% your error
A(0)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!