How can I extract data and match it from two different data??
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
kyoungin kang
el 12 de Feb. de 2020
Comentada: kyoungin kang
el 13 de Feb. de 2020
Hello.
for example, I have two data.
1 is [ 0 0 0 0 1 1 1 0 0 0 ] and
2 is [ 5 5 5 5 10 10 10 6 6 6 ]
What I want to do is that first find a value '1' position in data 1* 5th,6th,7th) and extract a data from same position in data 2.(10 10 10 )
in original dat there are more then 5000 sequence... :(
Is there any way to do this?
0 comentarios
Respuesta aceptada
the cyclist
el 12 de Feb. de 2020
Editada: the cyclist
el 12 de Feb. de 2020
If your first vector is only ones and zeros, then it is as simple as
idx = [ 0 0 0 0 1 1 1 0 0 0 ];
b = [ 5 5 5 5 10 10 10 6 6 6];
b(idx)
If the first vector has more general values, and you want the values of the second vector where the non-zeros are then
a = [ 0 0 0 0 2 1 6 0 0 0 ];
b = [ 5 5 5 5 10 10 10 6 6 6];
b(a~=0)
If you actually need the positions of the non-zero elements, then
pos = find(a);
Más respuestas (0)
Ver también
Categorías
Más información sobre Descriptive Statistics and Visualization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!