|
"Kirk" <kwythers.nospam@umn.edu> wrote in message <iukq42$o5b$1@newscl01ah.mathworks.com>...
> I am using mvnrnd() to create random climate in a multidimensional array. However, some of the values are nonsensical (such as precipitation values less than zero. To correct this problem, I tried to use an if statement to identify and replace negative precipitation values with 0.
>
> Here is the code which inserts the output of mvnrnd into the final 200 years of monthly climate rows, for columns 3 through 6, for all arrays i. Precipitation is in column 6.
>
> for i = 1:n;
>
> climate(12001:14400,3:6,i) = mvnrnd(muPost,sigmaPost);
>
> end;
>
> if climate(:,6,:) < 0
> climate(:,6,:) = 0;
> end
>
> Obviously my if statement is not doing what I think it should. Any suggestions would be appreciated. Thanks in advance.
Without an example of your input data I can't guarantee this will be applicable to your situation, but here is a simple example that accomplishes something similar using randomized data:
input = random('normal', 0, 1, 4,4);
input (:,:, 2) = random('normal', 0,2, 4,4);
idx = input(:,:,1) <0;
output = input(:,:,1);
output(idx) = 0;
input(:,:,1) = output;
|