I think I would suggest something like this:
NOC1 = Get_Control(F); %%get initial control limit
fault_state = 0;
for i = 1:(size(F,1))
abx = F(i,:); %%add the new value each time
MRSS= Get_Values(abx,NOC1); %%Works out the values of Q and T
%Calculate Q
Q_new = MRSS.Q;
Q = [Q; Q_new];
QLimit= [QLimit; QLimit_new];
% Calculate T
T_new= MRSS.T;
T= [T; T_new];
TLimit = [T2cfdLimit; T2cfdLimit_new];
% Update the model
abx = abx(2:end,:); %%takes away oldest value
if i > 5 && Q(i) > QLimit(i) && all(Q(i-4:i) > QLimit(i-4:i)) && fault_state == 0 %new fault detected
fault_state = Xwindow; %if a fault is detected, start a countdown
end
if fault_state > 0
QLimit_new = QLimit(end);
TLimit_new = TLimit(end); %%therefore not updating the limits during the fault
fault_state = fault_state - 1;
else
% Calculate new limits
NOC1 = Get_Control(abx);
QLimit_new = NOC1.QLimit;
TLimit_new = NOC1.TLimit;
end
end
Basically, the idea is to create a countdown timer. When you detect an error, start the timer. Only update the values when the timer is zero, otherwise hold on the old values. I can't debug this since I don't have your code, but I think this should be roughly what you want to do.