Extract all columns for a single row in a cell array

4 visualizaciones (últimos 30 días)
Riccardo Rossi
Riccardo Rossi el 11 de Mzo. de 2019
Respondida: KSSV el 11 de Mzo. de 2019
Hi everybody,
i have two cell array like the following:
A {1,1}
1
0
0
0
B {1,1}
12 34 54
11 31 51
26 44 94
15 54 58
I want to extract all the columns for single row in B based on A, like the following example:
C{1,1}
12 34 54
I made this script but it extracts only the first column value (in this case 12):
A {1,n}
B {1,n}
for k=1:n
C{k}=B{1,k,:,:}(A{1,k,:,:});
end
How can i do it?
Thank you a lot!

Respuesta aceptada

KSSV
KSSV el 11 de Mzo. de 2019
A {1,1} = [1
0
0
0] ;
B {1,1} = [12 34 54
11 31 51
26 44 94
15 54 58 ];
B{1,1}(logical(A{1,1}),:)

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by