Clear Filters
Clear Filters

Extract all columns for a single row in a cell array

4 views (last 30 days)
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!

Accepted Answer

KSSV
KSSV on 11 Mar 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}),:)

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!