could anyboby help me to solve the error
조회 수: 2 (최근 30일)
이전 댓글 표시
Bmax=20;
noise=10;
E = [2 3 0 0 5;
5 6 0 0 4;
1 9 0 0 3]
P = [1 5 0 0 6;
4 3 0 0 2;
7 8 0 0 9]
U=sort(E,'descend')
V=sort(P)
throughput =(Bmax.*log2(1+((V(i).*U(i))./(noise+(sum(U,1,i-1).*V(i))))))
If i run the code i am getting Error in
throughput=(Bmax.*log2(1+((V(i).*U(i))./(noise+(sum(U,1,i-1).*V(i))))))
Subscript indices must either be real positive integers or logicals.
Could anyone help me to solve the error.
댓글 수: 2
Adam
2018년 1월 15일
i is not defined anywhere in the code you gave us so could be anything.
This error is easy to locate though if you just use the stop/pause on errors option from the breakpoints menu in the editor and use the command line to investigate your variables when it stops. You will find that one of your indices into an array on that line is not a real positive integer or a logical.
The most obvious candidates for the error would seem to be that i is 0 or negative or floating point or that you have created a variable somewhere called 'sum' that it is trying to index into using U, which clearly contains 0s
채택된 답변
Greg Heath
2018년 1월 15일
i is undefined
However if i were defined U(i) would probably be incorrect because U is 2 dimensional.
You probably have to define a for loop over i
Hope this helps.
Thank you for formally accepting my answer
Greg
추가 답변 (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!