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
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
Prabha Kumaresan
Prabha Kumaresan 2018-1-15
sorry its my mistake where i indicates the number present in U and V matrix.could you please help me how to define i in the code in such a way i value needs to implemented in the throughput equation.

请先登录,再进行评论。

采纳的回答

Greg Heath
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by