I’m wondering how I can combine vectors in MATLAB in the following way: I have a vector
S= [0.1 0.2 0.1 0.3 0.1 0.5 1 3]
And a second vector with same length
B= [1 1 4 4 6 7 9 10]
Now I would need to have a vector A with as many elements as the potential numbers in B (in this example e.g 10) and this vector should contain the value of S when B’s content equals the index of A. And if there are several potential S values it should contain the mean of those. If there is no value in B that equals th index of A, A should contain Na.
So in this example
A= [0.15 NaN NaN 0.2 NaN 0.1 0.5 NaN 1 3]