How to rewrite normrnd?
Show older comments
Hello! Matlab beginner here. I'm trying to adapt a code sent by a colleague which uses the 'normrnd' function, but I don't have the Statistics Toolbox (we're running an old version of Matlab for equipment compatibility reasons). How would I rewrite this function for myself?
I have:
function nrmmatrix = nrmrnd(mu, sigma, sz1, sz2)
nrmmatrix = [];
for i = 1:sz1
for j = 1:sz2
nrmmatrix(i,j) = mu + sigma * rnd(n);
end
end
...But I have a feeling this isn't right!
Thanks very much in advance.
Answers (1)
Jeff Miller
on 11 Sep 2018
function nrmmatrix = nrmrnd(mu, sigma, sz1, sz2)
nrmmatrix = mu+sigma*randn(sz1,sz2);
end
Categories
Find more on Environmental Science 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!