Out of memory issue
Show older comments
I have to make a histogram about the times a variable is <=13, so I made this code but after about half an hour it crashed the site and said
Error code: Out of memory
Hw can I make it use less memory and execute quicker?
A=zeros(1,10000) %array to store the X values
for(j=0:1:10000) %rand 1000 times, if rand <=13, x++, 10000 times
x=0
for(i=0:1:1000)
data=randi([0,100])
if(data<=13)
x=x+1
end
end
A(1,j+1)=x
end
histogram(A) %histogram of value of x, and the times it had that value
Accepted Answer
More Answers (0)
Categories
Find more on Univariate Discrete Distributions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!