How do I get prctile function to work?
6 ビュー (過去 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!