Reputation: 549
I have a three dimensional array of simulated data (dimensions are 10000-by-16-by-312 or #trials by TimeSeries by horizons). I would like to replace values above / below a pre-specified threshold with the threshold values. I have calculated the threshold values for each individual time series in MinAcceptableVal(:,i)
and MaxAcceptableVal(:,i)
. When I run the code I do not receive an error message, but the values above the threshold are not cut off.
for i=1:nIndices
simulatedReturnsEVT1(simulatedReturnsEVT1(:,i,:)<MinAcceptableVal(:,i))=MinAcceptableVal(:,i);
simulatedReturnsEVT1(simulatedReturnsEVT1(:,i,:)>MaxAcceptableVal(:,i))=MaxAcceptableVal(:,i);
end
I have tried to use the code in a different form (see below) before and it worked perfectly. Matlab seems to be having problems with me introducing different cutoff levels for the different time series variables (i
).
simulatedReturnsEVT1(simulatedReturnsEVT1<-1)=-1;
simulatedReturnsEVT1(simulatedReturnsEVT1>1)=1;
I would be very happy about any Hints!
Upvotes: 1
Views: 48
Reputation: 45752
Try it like this:
for i=1:nIndices
slice = simulatedReturnsEVT1(:,i,:);
slice(slice < MinAcceptableVal(i))=MinAcceptableVal(:,i);
slice(slice > MaxAcceptableVal(i))=MaxAcceptableVal(:,i);
simulatedReturnsEVT1(:,i,:) = slice;
end
Upvotes: 1