필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Ricardo Duarte
Ricardo Duarte 2022년 2월 11일
댓글: Ricardo Duarte 2022년 2월 14일
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
Ricardo Duarte
Ricardo Duarte 2022년 2월 11일
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 2022년 2월 12일
use b = b' to get the same matrix size?

댓글을 달려면 로그인하십시오.

답변 (1개)

Catalytic
Catalytic 2022년 2월 12일
xa=1:length(Na);
xb=1:length(Nb);
Nb=Nb + trapz(xa,Na.*xa) - trapz(xa,Na.*xa);
  댓글 수: 1
Ricardo Duarte
Ricardo Duarte 2022년 2월 14일
Hello @Catalytic, thank you for your help, however I'm not understanding why you sum and subtract
trapz(xa,Na.*xa)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by