필터 지우기
필터 지우기

plot shifting while using histcounts

조회 수: 2 (최근 30일)
sani
sani 2020년 3월 16일
댓글: Rik 2020년 3월 16일
Hi,
I'm trying to compare 2 spectrums but I get this shifting in the X-axis (the blue spectrum is processed data out the red one), my suspition is that it happened since I'm using histocounts.
this is the plot script:
[X,~] = histcounts(X_table.energy,2744);
semilogy(X,'r')
% xlim([1 2000])
hold on
[Z,~] = histcounts(Y,2744);
semilogy(Z,'b')
% xlim([1 2000])

채택된 답변

Rik
Rik 2020년 3월 16일
You are specifying the number of bins, not the exact bins. Then when you are plotting you don't specify the x-value. If you change either of these the data should align again.
  댓글 수: 4
sani
sani 2020년 3월 16일
thanks a lot!
I did read the documentation but didn't understand the that I need to use edges.
Rik
Rik 2020년 3월 16일
Well, you don't need to, but if you want to compare two sets of data you should be using the same bins, so you can't let Matlab figure out the bins automatically.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by