필터 지우기
필터 지우기

best way to present data from histcounct

조회 수: 1 (최근 30일)
sani
sani 2021년 2월 16일
답변: Rik 2021년 2월 17일
Hello,
I used the histcount since I'd like to scale a histogram to X100 and compare it to another data set.
I'd like to present the data as a line plot, but I still get the bins marked (image added, the marked area is the one I'd like to be removed).
is there is a way to remove those lines?
alternativly, is there is another way to rescale the data that is motre recomended?
  댓글 수: 2
Rik
Rik 2021년 2월 16일
Can you attach your data and the code to create this figure?
sani
sani 2021년 2월 17일
Yes those are the files, thanks

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

답변 (1개)

Rik
Rik 2021년 2월 17일
The cause of your problem is illustrated below:
data=randi(5,100,1);
BinEdges=linspace(0,6,14);
[A,E] = histcounts(data,BinEdges);
x=E(2:end)-diff(E);%find the middle of each bin
plot(x,A)
Do you see how there are bins with 0 counts? This results in your graph filling up, while you want a hull.
There are many strategies to deal with this. One of those is to mark the 0 positions with NaN and use tools like fillmissing to estimate the correct values for those bins.
S=load('dataset.mat');temp=S.temp; %always load to a variable when loading a mat file
[A,E] = histcounts(temp,16384);
x=E(2:end)-diff(E);%find the middle of each bin
B=A;B(B==0)=NaN;%mark zeros with NaN
B=fillmissing(B,'spline');
plot(x,B)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by