문제

I have a 1x4225 vector that its elements are between 0 and 1 and I want to plot their probability density function in matlab. In the case of ksdensity() the problem is that the probability sometimes gets more than 1. I also tried the code below to do that:

A= [1x4225];           
xRange = 0:1;                
N = hist(A,xRange);        
plot(xRange,N./numel(A))

But because of huge number of my data it made an ambiguous plot that consists of some vertical lines and is useless for me. So is there any way to solve this problem or any other way to do this in matlab that shows each element as a separate point in pdf plot ?

도움이 되었습니까?

해결책

When you do xRange = 0:1; you get a 2-element vector [0 1]. That is probably not what you want. Specify a step like:

xRange = 0:0.01:1;

Plotting each element as a point is accomplished in MATLAB with the line specifier argument, like plot(xRange,N./numel(A),'*'). However, for a histogram with only a small number of bins, you might be better off with bar(...). If you go with a finer step, then plotting might be better.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top