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.

Antworten (1)

Jeff Miller
Jeff Miller am 11 Sep. 2018

1 Stimme

function nrmmatrix = nrmrnd(mu, sigma, sz1, sz2)
nrmmatrix = mu+sigma*randn(sz1,sz2);
end

Kategorien

Mehr zu Environmental Science finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 10 Sep. 2018

Beantwortet:

am 11 Sep. 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by