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!