I have two numerical arrays of 6538x1 data, let's say diameter and weight. I would like to create multiple sub-arrays whenever diameter falls within a desired range. For example, my first sub-array should include diameter within a range of 10^0.65 to 10^0.70 and the corresponding weight values. The second sub-array should include diameter within a range of 10^0.70 to 10^0.75 and the corresponding weight values and so on. I would then like to find the mean values of diameter and weight from each sub-array and create a plot that shows correlations between the two.
I have tried creating a logical index and then finding average values of diameter that fall in the desired range. For example, the lines below can generate average values of diameter for my first desired sub-array but how can I get the corresponding values of weight and calculate the mean for that?
subarray1 = diameter <10^0.7 & diameter>=10^0.65;
meandiameter1 = mean(diameter(subarray1));