I have a simple question that I can not solve.
I have a 8760 x 1000 matrix in which some values are negative, and some are larger than 1. The matrix represents 1000 simulation outcomes for 8760 hourly wind energy capacity factors in a year. I want to replace the negative values with zero, and the values that are larger than 1 with 1. Also I want to count how many values I have replaced in any given run.
So far I have been first counting values that are above 1 and below 0 for the entire matrix using the numel function. This gives me just one number for the entire matrix. However I would like to obtain the number of values below 0 and above 1 for all of the 1000 simulations. Then after I get this I want to run a loop for replacing these values with 0 (when beloe zero) and 1 (when above one).
So far this is the code I have been using:
CountIF_exc_1 = numel(SimWind_CapFac_UP(SimWind_CapFac_UP>1));
CountIF_neg = numel(SimWind_CapFac_UP(SimWind_CapFac_UP<0));
SimWind_CapFac_UP_corrected = zeros(SimHours,numberSim);
if SimWind_CapFac_UP_corrected(x,y) > 1
SimWind_CapFac_UP_corrected(x,y) = 1;
elseif SimWind_CapFac_UP_corrected(x,y) < 0
SimWind_CapFac_UP_corrected(x,y) = 0;
This is however resulting in all zeros.
In summary could you please help me develop code to: a) count values that are below 0 and above 1 for each individual simulation run (the 1000 runs) and b) loop through the 8760 x 1000 matrix to replace these values with either 0 or 1.
Thanks a lot!