I have data in two columns that looks as follows:
A B 1,265848208 3 -0,608043611 0 -0,285735893 0 0,006895134 7 0 7 -0,004526196 7 0,176326617 10 -0,159688071 2 0,22439945 2 -0,991045044 1 0,178022324 1 -0,270967397 4 0,285849994 4 1,881705539 23 1,057184204 10 NaN 10
For all unique values in B I want to extract the corresponding value in column A and move it to a new matrix. I’m looking to then compute the mean of all the corresponding values in A and use as a dependent variable (weighted by no of observations per value in B) in a regression with the common value of B being the independent variable to reduce noise. Any help would on how to do this in Matlab (except running the regression) would be great!
Thanks
Oscar
Here is an efficient solution:
The result: