Effacer les filtres
Effacer les filtres

How to align the center of mass of two density functions?

1 vue (au cours des 30 derniers jours)
Ricardo Duarte
Ricardo Duarte le 11 Fév 2022
Commenté : Ricardo Duarte le 14 Fév 2022
Dear all,
I have two density functions which I would like to align their x-axis.
I was thinking to align then using the barycenters but I don't know how to do it in matlab.
I would like to do this to multiply later these two density functions.
Can anyone give me a clue on this?
Thank you in advance
  3 commentaires
Ricardo Duarte
Ricardo Duarte le 11 Fév 2022
In the attached file you may find two matrices. These matrices represents an area.
What I need to do is:
- to calculate the pdf of both matrices. For that I'm using the following code:
Na=histcount(a,'normalization','pdf');
Nb=histcount(b,'normalization','pdf');
Now I want to align both distributions according to their center (barycenter).
Thank you.
yanqi liu
yanqi liu le 12 Fév 2022
use b = b' to get the same matrix size?

Connectez-vous pour commenter.

Réponses (1)

Catalytic
Catalytic le 12 Fév 2022
xa=1:length(Na);
xb=1:length(Nb);
Nb=Nb + trapz(xa,Na.*xa) - trapz(xa,Na.*xa);
  1 commentaire
Ricardo Duarte
Ricardo Duarte le 14 Fév 2022
Hello @Catalytic, thank you for your help, however I'm not understanding why you sum and subtract
trapz(xa,Na.*xa)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by