How do I get prctile function to work?
조회 수: 4 (최근 30일)
이전 댓글 표시
Here is my code for what I am trying to do:
Iterations = 5000;
for i = 1:Iterations
format rat;
Beta = 8/13;
U = rand(1);
condition1 = U <= 8/13;
T(condition1) = sqrt(8*U/13);
condition2 = U > 8/13;
T(condition2) = 1 - sqrt(5*(1 - U)/13);
N = floor(80 + 130*T);
Zmatrix = floor(170 + 316*rand(1,N));
x(i) = sum(Zmatrix);
end
hist(x)
m = mean(x)
v = var(x)
prctile(x,25)
Basically, I have created an array of value x, and successfully created a histogram from the data. However, the prctile(x,25) function is not working.
What do I have to do to get Matlab to understand the prctile function? I have version 7.12.0 (R2011a). Any ideas?
댓글 수: 2
the cyclist
2013년 9월 10일
Can you be more specific by what you mean by "not working"? Give the full error message if you get one. If it runs, but gives a value that you think is wrong, please explain why.
답변 (2개)
the cyclist
2013년 9월 10일
prctile() is a function in the Statistics Toolbox. Type
ver
at the command prompt to see your list of available toolboxes.
댓글 수: 3
the cyclist
2013년 9월 10일
That is definitely the issue.
Your options:
- Buy the Statistics Toolbox
- Program this one function yourself
- Look in the File Exchange to see if someone has contributed a percentile function that you could download and use.
Each of these options has pros and cons, depending on your knowledge, wealth, and time available.
the cyclist
2013년 9월 10일
I don't know why you chose
format rat
which I am going to ignore for now.
I get that
m = 4.8e4
and
prctile(x,25) = 4.3e4
(approximately).
Both of these values look quite reasonable, given your histogram. Do you get something different? I am running R2013a.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!