Why do I get the error "Subscript indices must be real positive integers or logicals?"
조회 수: 1 (최근 30일)
이전 댓글 표시
for k=1:length(x)
d=T(V)-Dft(V)-Dw(V);
end
max = max(d);
댓글 수: 0
채택된 답변
Walter Roberson
2018년 3월 1일
Your line
max = max(d);
first calls upon the built in MATLAB function max to find the maximum of d. It then redefines the name max to be associated with a variable with that value, blocking the use of max as a function. The next time you attempt to take max() of anything, max(d) would be interpreted as an attempt to index the variable named max with the index given in d, which can only work if d is the value true or false or is something numeric that consists entirely of 1's.
댓글 수: 0
추가 답변 (1개)
Paul Shoemaker
2018년 3월 1일
Two points...
First, it's very difficult to answer your question without number examples that we can test.
Second, you have "d" in a FOR loop, but do not appear to be using the loop index "k" for anything in the loop. So, why loop at all? I suspect this is a typo.
Paul Shoemaker
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!