I have a column vector A, corresponding to which I need to fill a vector C, the same size as A.
The value of C would be assigned from the "look up" table B-CD.
For the closest matching value of B to each element in A, the corresponding CD will be filled in to C.
So for the example below, for A= 0.35, 0.95, the C should be 200, 400.
How do I assign correct values to C?
%This code does not really work
C = zeros(length(A),1);
B=[0.1 0.4 0.8 1];
CD=[100 200 300 400];
for ii = 1:length(B)
diff = abs(B(ii) - A);
if(diff < minDiff)
B_index = ii;
minDiff = diff;