Using a logical matrix as size input for lognrnd

1 view (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 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);

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox 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!