Problem binning data with histc()

Hello,
I am trying to bin velocity and acceleration data using histc(). However, I am getting an error. I would be grateful if somebody could advise me on how to do it correctly?
I have velocity and acceleration in 2 columns. For example
Vel Acc
1 0.28
2 0.28
2 0.00
3 0.28
5 0.56
6 0.28
I am trying to bin the data into the bins, specified by the bin edges.
edges = {0:1:120, -4:0.1:4}
I was trying to use the histc(). Using the code:
n=histc(Data,'Edges',edges);
But I am getting the error:
Edge vector must be monotonically non-decreasing.
Could you tell me the correct way of defining the edges of the bins. I also tried a vector but that wouldn't work.
Ultimately, I trying to create a plot like this.
Thank you

 채택된 답변

Walter Roberson
Walter Roberson 2013년 1월 23일

0 개 추천

댓글 수: 3

Hello,
Thank you for your suggestions. Could I use hist3() instead?
edges = {-4:0.1:4, 0:120}
hist3(Data,'Edges',edges);
However, this code plots the data but does not return a variable telling me how much data is in each bin. Is there a way to get this information from the histogram?
Thank you
N = hist3(Data, 'Edges', edges);
N would then be counts and nothing would be plotted.
John
John 2013년 1월 23일
Thank you for your help.

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

추가 답변 (1개)

Wayne King
Wayne King 2013년 1월 23일
편집: Wayne King 2013년 1월 23일

0 개 추천

Why do you think you can use the syntax
histc(data,'Edges',edges)
that is not a supported syntax.
edges must be a vector or matrix. It is not a name-value pair as you have entered.
To do it correctly, something like
Data = randn(1000,1);
Edges = -3:0.5:3;
N = histc(Data,Edges);

카테고리

도움말 센터File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

태그

질문:

2013년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by