check the row that has at least one non zero element, except one row

I have a matrix that has 20 rows and I have to calculate some thing only on the rows that have at least one element, except one row that is specified by a variable, I use this:
for i = setdiff(1:r, row)
for the specific row exception part, but how can i mix this with, for example, any(matrix,2)?

2 comentarios

I'm a little confused what you're asking. Are you looking for how to code the check for non-zero elements in each row?
let me explain it this way. I have to build a matrix called interference that the elements have to be like this:
interference(1,1)=[gain(2,1)/mbw(2)]+[gain(3,1)/mbw(3)]+[gain(4,1)/mbw(4)]
considering the interference is a 4*4 matrix. i have gain and mbw arrays.

Iniciar sesión para comentar.

Respuestas (1)

idx = setdiff(1:r, row)
any(matrix(idx,:),2)

4 comentarios

I need to do something like this:
for i=1:r
for j=1:c
Interference(i,j)= ChannelGainUN(i,j)/MaxBandwidthOfEachRRH(i)
end
end
but for each i, ChannelGainUN(i,j)/MaxBandwidthOfEachRRH(i) should be calculated for all r's excepr r=i, can I do it with this?
Stephen23
Stephen23 el 12 de Feb. de 2018
Editada: Stephen23 el 12 de Feb. de 2018
Interference = zeros(r,c);
for idr = 1:r
idx = setdiff(1:r, idr);
for idc = 1:c
Interference(idr,idc) = ChannelGainUN(idx,idc)/MaxBandwidthOfEachRRH(idx);
end
end
thank you for this, I have a question about the first answer, I mean:
idx = setdiff(1:r, row)
any(matrix(idx,:),2)
how can I use both these in a for? in shape of the second answer
for idr = 1:r
idx = setdiff(1:r, idr);
any(matrix(idx,:),2)
end

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de Feb. de 2018

Comentada:

el 13 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by