Using a logical matrix as size input for lognrnd

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Walter Roberson
Walter Roberson il 15 Giu 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);

Più risposte (0)

Categorie

Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by