I have the following variables: Matrix A with the size 75×1, Matrix B with the size 2400×2, Cell C with the size 75×1.
I am trying to insert B(i,2) into C{j}, if it passes the condition (A(j,1)-0.25)<B(i,1)<(A(j,1)+0.25). I am doing this so that later I can take the averages of each element of C. The code I have written for this is not working the way it should. It puts all the elements of B(:,2) into each cell of C. Any help would be appreciated. Thanks in advance!
C = cell(75,1);for i = 1:75 for j = 1:2400 if (A(i,1)-0.25) < B(j,1) < (A(i,1)+0.25) C{i}(end+1)= B(j,2); end end endD = cell(size(C));for o = 1:numel(D) D{o} = mean(C{o});endD = cell2mat(D);
Best Answer