Average of the values for duplicate keys in a cell array of (key,value) in matlab -
i have 2 columns in cell array key , value 
i want single value corresponding every key removed duplicate value as: wd=finalalp93val; [~,idx]=unique(strcat(wd(:,1),wd(:,2)) , 'rows') finalalp93val = wd(idx,:)
but resulted in higher variation in result. how can average values same key in matlab. number of rows each key variable here. (here key first column , value second column , want achieve avg of values each key.)
here's how using minimal example:
key=wd(:,1); val=wd(:,2); ukey=unique(key); n=1:numel(ukey) mean_value(n)=mean(val(key==ukey(n))); end so can present them follows:
[ukey(:) mean_value(:)]
Comments
Post a Comment