Scale one scattered dataset to fit another scattered dataset

5 vues (au cours des 30 derniers jours)
Vahid Askarpour
Vahid Askarpour le 18 Nov 2018
Commenté : KingsOz le 2 Août 2022
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

Réponse acceptée

dpb
dpb le 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);
  2 commentaires
dpb
dpb le 19 Nov 2018
...moved to comment... dpb
Thanks dpb. This is exactly what I was looking for.
Cheers,
Vahid
KingsOz
KingsOz le 2 Août 2022
I have a similar question in which I am trying to fit one dataset with another dataset. Dataset 1 is defined by (x,y) where x and y are colum vectors. Dataset 2 is defined by (z,t) where z and t are also column vectors. The challenge here is that the scaling factor needs to be of the form: M^z1 * N^z2 * P^z3 * U^z4
where M, N, P and U are constant based of the system properties and can be readliy calcuated. Howver, I am not know how to use matlab to calculate the values of z1, z2, z3, and z4 for the best fit possible. Can matlab handle this problem?
Thanks,
Kings

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 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.
  1 commentaire
dpb
dpb le 19 Nov 2018
Trudat, IA, but this appears to be simply a scaling problem as OP defined it, however.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Descriptive Statistics and Visualization dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by