I have a matrix like below.
2 1 0.020000000
2 1 0.020000000
2 1 0.020000000
2 1 0.020000000
2 2 0.434776340
2 2 0.392582120
2 2 0.549031660
2 3 0.0306320700000000
2 3 0.0336107500000000
3 1 0.0200000000000000
3 1 0.0200000000000000
3 1 0.0200000000000000
3 1 0.0200000000000000
3 1 0.0200000000000000
3 2 0.301534290000000
3 2 0.381151280000000
3 2 0.227146390000000
3 2 0.402937460000000
3 3 0.0773929900000000
3 3 0.0220243800000000
3 3 0.0859914800000000
I want to check the first columns values if it's 2 then check the next column and if its value is 1 calculate the mean of all values in column3 so it would be like this:
The mean of 3nd columns values and put the it in a different matrix.
2 1 0.020000000
2 1 0.020000000
2 1 0.020000000
2 1 0.020000000
Then try this process for 2 2, 2 3, 3 1 and so on.
The values of 2nd column is either 1,2 or 3 but the values of first column are in range of 2-5000. I tried like this but it doesn't work properly:
[ii,jj]=find((S(:,2)==1)); //S is the matrix i mentioned earlier
out=S(ii,[1,3]);
for i=2:3
if out(:,1)==i
Mean(i) = mean (out(i,2));
end
end
Thanks!