Filter löschen
Filter löschen

Extract all columns for a single row in a cell array

4 Ansichten (letzte 30 Tage)
Riccardo Rossi
Riccardo Rossi am 11 Mär. 2019
Beantwortet: KSSV am 11 Mär. 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!

Akzeptierte Antwort

KSSV
KSSV am 11 Mär. 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}),:)

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by