Borrar filtros
Borrar filtros

Obtain cell according to a corresponding value

1 visualización (últimos 30 días)
Dimitris Kokkinos
Dimitris Kokkinos el 4 de Dic. de 2014
Editada: Azzi Abdelmalek el 4 de Dic. de 2014
Hello everyone!I have 2 cell arrays. The first one is 5x2:
A={[1;2;3;4;5] 3;[12;13;14] 2;[1;2;3;4;8;9;10;22;23;24] 6;[4;5;6;8;9] 4;[5;6;7] 6};
The second one is 6x1
B={[32;21;13];[1;2;35];[5;6;7;8;9;0;2;3];[2];[1;3;5;7;9];[5;6;7]}
What I need is to create another cell array which will contain cells from array B selected and sorted according to A(:,2). The extracted result should be:
R={[5;6;7;8;9;0;2;3];[1;2;35];[5;6;7];[2];[5;6;7]}
R(1)=B(3)
R(2)=B(2)
R(3)=B(6)
R(4)=B(4)
R(5)=B(6)

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 4 de Dic. de 2014
R=B(cell2mat(A(:,2)))

Más respuestas (0)

Categorías

Más información sobre Data Types 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