logical index replace values
Mostrar comentarios más antiguos
Hi
mBall(1:15001,4) = 0;
-3.42 -24.55 5.19 0
-3.01 -24.59 5.66 0
-2.59 -24.64 6.11 0
-2.19 -24.69 6.53 0
-1.78 -24.73 6.91 0
-1.38 -24.79 7.28 0
-0.98 -24.84 7.63 0
% this is what an exsample of what my mBall looks like
% I have an array c that consist of 3786x2
% I'm trying to insert values from c(:,2) in mBall(:,4)
% But only in the rows equal to value in c(:,1)
c =
2 1
3 1
4 2
5 3
7 3
% mBall should look like this afterwards
mball =
-3.42 -24.55 5.19 0
-3.01 -24.59 5.66 1
-2.59 -24.64 6.11 1
-2.19 -24.69 6.53 2
-1.78 -24.73 6.91 3
-1.38 -24.79 7.28 0
-0.98 -24.84 7.63 3
7 comentarios
madhan ravi
el 26 de Mzo. de 2019
Please illustrate with a short example.
Morten Jørgensen
el 26 de Mzo. de 2019
Editada: Morten Jørgensen
el 26 de Mzo. de 2019
madhan ravi
el 26 de Mzo. de 2019
I have no idea why some people make even a simple problem harder to be understood.
Morten Jørgensen
el 26 de Mzo. de 2019
Editada: Morten Jørgensen
el 26 de Mzo. de 2019
madhan ravi
el 26 de Mzo. de 2019
Editada: madhan ravi
el 26 de Mzo. de 2019
Rows equal to c(:,1) show us how they are matched. It’s not clear.
Morten Jørgensen
el 26 de Mzo. de 2019
Morten Jørgensen
el 26 de Mzo. de 2019
Respuestas (1)
Read about logical indexing.
idx = 0 < output5 & output5 < 1 ;
output = output5(idx);
1 comentario
KSSV
el 26 de Mzo. de 2019
If you want row number find(idx)
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!