Extracting a specific element from each cell within cell array

前端 未结 3 707
轻奢々
轻奢々 2021-01-21 01:24

I have a cell array A of size 10x10 (say). Each cell in turn contains a 5x20 matrix. I want to select (i,j) element from each

3条回答
  •  渐次进展
    2021-01-21 02:14

    CELL2MAT gets all the data from a cell array that consists of numeric data only, into a numeric array. So, that helped us here. For your original problem, try this -

    celldim_i = 10;
    celldim_j = 10;
    
    block_size_i = 5;
    block_size_j = 20;
    
    search_i = i; %// Edit to your i
    search_j = j; %// Edit to your j
    
    A_mat = cell2mat(A);
    out = A_mat(search_i+block_size_i*(0:celldim_i-1),search_j+block_size_j*(0:celldim_j-1))
    

提交回复
热议问题