MATLAB: Are Tables or Structures better for this scenario

MATLABstructurestables

I have an array (D) of numbers (double, 120×1). I want to search the data (UINT32) in a structure for occurrences of these numbers from the array and record the indices. In the 2nd column, I want to search in the data and record the channel of these indices.
Tables: I know that the number of indices for each of the 120 numbers in the array will not be the same, that leads me to think that trying to collect the data in a table is not a good idea because the number of rows will not be the same. Ideally I would like a 240 column table indices and channel for the 120 numbers in array D.
Structures: I am thinking of creating a for loop to achieve this. How can I get a structure with 120 tabs for each of the numbers in the array and two columns in each tab, one for the indices and another for channel?
following is the bit of code I am trying to fix:
if true
% code
D = [1034;120;71;73;74;.....];
for ind = 1:length(D)
s1.(D{ind}) = find(Raw.Run1.message.id==(length(D{ind})));
s2.(D{ind}) = Raw.Run1.message.chan(s1.(D{ind}));
end
If there is a more efficient way to do this (neither structures or tables), I am open to that as well.
Thanks!

Best Answer

Perhaps something like this (untested, because you have not given us any sample data):
S = load('data.mat');
F = S.Raw.Run1.message.id;
D = [1034,120,71,73,74];
W = cell(size(D));
for k = 1:numel(D)
W{k} = find(D(k)==F);
end
Read this to know about cell array indexing: