Matlab - How to compare values in a cell array? -


i have set of inputs , 1 output declared in cell array that:

a = {'a', 'f', 'c', 'b';      'b', 'f', 'c', 'a';      'a', 'f', 'b', 'c';      'c', 'f', 'b', 'a';      'c', 'f', 'a', 'b';      'b', 'f', 'a', 'c' } 

where first column output, , rest inputs used, each output.

i need compare values reduce calculation time. so, thing is, equals outputs, wanna know if inputs same, important remark.. order of values desn't metter, so, when comparing f c b f b c same.

i need because, acttualy, data set 5040 x 7 cell array , need put them intorpolation function.

i thought in like

if value of output column equal value of same column, check if value of inputs same, using, ismember function. can not arrive code works.

any help, please?

first, since don't care order of inputs, sort each of rows:

[t, n] = size(a); t = 1:t   asorted(t,1)   = a(t,1);   asorted(t,2:n) = sort(a(t,2:n)); end 

now want find of duplicate rows. simple way first convert character array, , use unique function --

b = cell2mat(asorted); [c, ii, jj] = unique(b,'rows'); 

now c contains unique rows of b, ii contains indexes of unique rows, , jj labels each of rows of b depending on unique value has.

if wanted filter out of duplicate rows a, can do

afiltered = a(ii, :); 

this results in:

afiltered =      'a'    'f'    'b'    'c'     'b'    'f'    'a'    'c'     'c'    'f'    'a'    'b' 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -