Using a logical matrix as size input for lognrnd

1 Ansicht (letzte 30 Tage)
Matthew Vincent
Matthew Vincent am 15 Jun. 2012
I am attempting to add random variation to a matrix of calculated values. The problem Is that I am attempting to add the log-normal error to only certain values of the original matrix.
GeneratedCatch(Catch_Active) = Catch_pred(Catch_Active) .* lognrnd(0, log((x(939)*x(319))^2 + Catch_variance(Catch_Active) + 1) , Catch_Active);
Catch_pred, GeneratedCatch and Catch_variance are 137 x 11 double matrices Catch_Active is a 137 x 11 logical matrix
The lognrnd accepts logical matrix but stores it as a 1 x 1 cell. Is there some way to get it to recognize the logical matrix for use as dimensions?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 15 Jun. 2012
Try
GeneratedCatch(Catch_Active) = Catch_pred(Catch_Active) .* lognrnd(0, log((x(939)*x(319))^2 + Catch_variance(Catch_Active) + 1) , nnz(Catch_Active), 1);

Weitere Antworten (0)

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by