Could anyone help me to solve the error

4 visualizaciones (últimos 30 días)
Prabha Kumaresan
Prabha Kumaresan el 15 de En. de 2018
Comentada: Walter Roberson el 16 de En. de 2018
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)
for k=1:3
throughput =(Bmax.*log2(1+((V(k).*U(k))./(noise+(sum(U,1,k-1).*V(k))))))
end
If i run the code i am getting Error using sum
Trailing string input must be 'double', 'native', 'default', 'omitnan' or 'includenan'.
Error in (line 15) throughput =(Bmax.*log2(1+((V(k).*U(k))./(noise+(sum(U,1,k-1).*V(k)))))).
Could anyone help me to solve the error

Respuestas (1)

Jan
Jan el 15 de En. de 2018
Editada: Jan el 15 de En. de 2018
The error message gets clear, if you read the documentation:
doc sum
Please do this before you ask in the forum if you have a problem with a command.
What do you want to calculate by sum(U,1,k-1)? While the 2st input is the array to sum up, the 2nd is the dimension to operate on. But what is the purpose of "k-1"? Because you did not explain (e.g. in a comment) what the code should do, I cannot suggest a solution.
By the way: The variable "throughput" is overwritten in each iteration. Maybe you want:
throughput(k) = ...
  4 comentarios
Jan
Jan el 16 de En. de 2018
Editada: Jan el 16 de En. de 2018
@Prabha Kumaresan: I guess you mean:
sum(1:k-1)
or
sum(U(1:k-1))
Sorry, Prabha, there is not way to avoid reading the documentation. If you have a problem with a command, start here:
doc sum
Trying sum(U,1,k-1) to solve "U is going to take the lower limit 1 to upper limit k-1" is pure guessing. This will not work for a computer language. Come on, this is your 163.th question in this forum.
Walter Roberson
Walter Roberson el 16 de En. de 2018
The original equation has seemingly been posted several times now. It does not select a subset of U to add: in the original equation i appears to be a free variable so the complete i is being selected each iteration of the summation, so the summation would collapse into a multiplication by the number of items being summed. It is, of course, possible that the posted equation has been incorrect multiple times.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by