MATLAB Answers

How to create a smoothed histogram and compute it's derivative magnitude in matlab

조회 수: 84(최근 30일)
Tolentee
Tolentee 29 Feb 2016
Edited: Mike Garrity 2 Mar 2016
How can I created a smoothed histogram in matlab and I will also like to know how I can compute it's derivative magnitude.
(Assume I want to do that for a vector e.g. y = randn(1,500))

  댓글 수: 0

로그인 to comment.

답변 수 (2)

Mike Garrity
Mike Garrity 2 Mar 2016
Mike Garrity 님이 편집함. 2 Mar 2016
If you have the statistics toolbox, you might want to consider ksdensity.
x = [randn(300,1); 5+randn(300,1)];
histogram(x,'Normalization','probability')
[f,xi] = ksdensity(x);
hold on
plot(xi,f)

  댓글 수: 0

로그인 to comment.


Richa Gupta
Richa Gupta 2 Mar 2016
If you have the Curve Fitting Toolbox, you can use the 'smooth' function for creating a smoothed histogram. For computing the derivative magnitude, you can use the 'diff' function. A sample code is below:
y = randn(1,500);
x = smooth(y);
z = diff(y);

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by