# Scale one scattered dataset to fit another scattered dataset

25 views (last 30 days)
Vahid Askarpour on 18 Nov 2018
Commented: dpb on 19 Nov 2018
I have two datasets of scattered points. Dataset 1 is defined by (x,y) where x and y are column vectors. Dataset 2 is defined by (z,t) where z and t are column vectors. The four column vectors are of the same size. I would like to scale dataset 1 by a factor (which I do not know) such that the scaled result is the best fit to dataset 2. I do not have a function that defines either datasets so I cannot use lsqcurvefit because I do not have the function "fun".
Is it possible to do the above with Matlab?
Thanks,
Vahid

dpb on 19 Nov 2018
Sure, your "equation" to minimize in least-squares sense is D1(x,y)-k*D2(t,z)
function sse=sseval(k,D1,D2)
sse=sum((D1-k*D1).^2);
and use that as the functional for fminsearch. It expects a function of only the one vector, x, of unknown coeffiecients so define an anonymous function that incorporates the data in it --
fun = @(x) sseval(x,D1,D2);
the values of D1, D2 in the workspace at the time of the definition of fun are embedded into the function definition itself automagically.
x0=1; % starting guess; perhaps the rms ratio of the two would be better if far from 1
bestk=fminsearch(fun,x0);
dpb on 19 Nov 2018
...moved to comment... dpb
Thanks dpb. This is exactly what I was looking for.
Cheers,
Vahid

Image Analyst on 19 Nov 2018
To align/match one scattered set of points to another, you should search for "Point Matching Algorithms"
It's not a trivial problem. It has been researched a lot in the astronomy community. One famous algorithm is the Groth algorithm and has been used to match things like star patterns from the Hubble Space Telescope to identifying whale sharks from their spot patterns.
dpb on 19 Nov 2018
Trudat, IA, but this appears to be simply a scaling problem as OP defined it, however.