MATLAB: Can anyone advise a code to convert two arrays, say A and B, where A is (111,2) and B(38,2) elements, to two matching scaled arrays each (200,2) so the data can be compared

re-scaling array dimensions

I have two arrays A and B which range in values from 1 to 10,000 in column 2. A is (111,2) and B is (38,2). I can use the code below to select a sequence of values from column2 closest to value 50, 100,150… etc, manually, each corresponding to a 0.5% increment. The intent is to arrive at two arrays, say C and D, each of which are dimension (200,2) with values in column 1 ranging 0 to 200 each being one half percent step, and the value in column 2 representing the column 1 bin count in each of A and B corresponding to that percentage increment. I cannot work out how to treat that value as a variable so I automate the search.
[min_val,ii]=min(abs(A(:,2)-50)); C(1,1)=1; C(1,2)=A(ii,1);
Cheers Bob Fitzell

Best Answer

Perhaps:
bin = linspace(1, 10000, 200).';
binA = histcounts(A(:, 2), bin);
binB = histcounts(B(:, 2), bin);
C = [bin.', binA(:)];
D = [bin.', binB(:)];
This is untested (I do not have a modern Matlab with histcounts at the moment) and I'm not sure if it matches your needs.