Hello,
I want to calculate mean of rows with multiple criteria. Below is the for loop which I am using, however I get error :Subscripted assignment dimension mismatch error. It may be due to when it looks for no. of rows to calculate mean, if it finds only one row, then the calculated mean is scalar? If so I want to keep the original row, instead of calculating the mean, Could you please help in this regard how to adjust the script?
Where X is a 5467-by-513 matrix , id is a 143-by-1 vector and wkno is a 44-by-1 vector
for ii=1:size(id,1); for jj=1:size(wkno,1); tst(ii,jj)= X(:,1)==id(ii,1) & X(:,2)==wkno(jj,1); M(ii,jj)=mean(X(tst,:)); endend
Many thanks
Best Answer