Reputation: 2617
I would like to access the lower triangular part of a (square) table with cell elements. I tried the tril
function, but it doesn't work for input arguments of type 'cell'. Is there any workaround? Thanks.
Upvotes: 0
Views: 27
Reputation: 112679
Is this what you want?
c = {1, [2 3], 4; [5 6 7], [8 9], 10; 11, 12, [13 14]}; %// example 3x3 cell array
mask = tril(true(size(c,1), size(c,2))); %// creat mask
result = c(mask); %// index cell array with mask
This produces a column cell array with the selected cells in column-major order:
result{1} =
1
result{2} =
5 6 7
result{3} =
11
result{4} =
8 9
result{5} =
12
result{6} =
13 14
Upvotes: 2