2
votes

In my cell array test = cell(1,2,20,14); I want to find numeric values in the subset test(:,1,1,1).

For example test(:,:,1,1) looks like this:

>> test(:,:,1,1)

ans = 

[     0]    [0.1000]    [57]
[0.9000]    [0.9500]    [73]

I want to find the index of the cell containing 0.9 in the first column, so I can access the third column (in this case value 73). I tried:

find(test{:,:,1,1} == 0.9) which gives:

Error using == Too many input arguments..

How can I find the respective index?

Thanks.

2

2 Answers

2
votes

Try this to access that third column value directly -

cell2mat(test(vertcat(test{:,1,1,1})==0.9,3,1,1))

Edit 1: If you would like to test out for match w.r.t. the first two columns of test's subset, use this -

v1 = reshape(vertcat(test{:,[1 2],1,1}),[],2)
cell2mat(test(ismember(v1,[0.9 0.95],'rows'),3,1,1))
1
votes

Just add brackets [] around test{:,:,1,1}. This wraps the different cell values together to one vector/matrix. Like this:

[index1, index2] = find([test{:,:,1,1}] == 0.9)