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 enter image description here

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

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -