create a new matrices by using existing matrices
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
tevzia
el 13 de Nov. de 2013
Respondida: Vivek Selvam
el 13 de Nov. de 2013
Hi,
I try to create a new matrices by using specific condition from existing matrices(its a data file) for example I have
a= [1,2,10;
1, 3, 20;
1, 4, 5;
1, 5, 7;
2, 3, 3;
2, 4, 1;
2, 5, 3;
3, 4, 6;
3, 5, 4;
4, 5, 8];
(first and second column are points and third one is the distance of each other) I want point number 2, 3 and 4 in the new matrices (those numbers (x) are come from another matrices(y) which are index of zeros)
x=find(y==0);
result supposed to be (just those numbers, not all of them)
b=[2,3,3;
2,4,1;
3,4,6];
not like this
b=[2,3,3;
2,4,1;
2,5,3;
3,4,6
3,5,4];
I am sorry if i cant explain well or it seems like do for me. I appreciate for some tip
0 comentarios
Respuesta aceptada
Vivek Selvam
el 13 de Nov. de 2013
Hope this helps.
x = a(:,1)
y = a(:,2)
want = [2 3 4]
choose = ismember(x,want) & ismember(y,want)
a(choose,:,:)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!