%% Reset Degradation Model
% Load training data, which is a degradation feature profile for a component.

load('expRealTime.mat')

% For this example, assume that the training data is not historical data. When there is no historical data, you can update your degradation model in real time using observed data.
%
% Create an exponential degradation model with the following settings:
% \theta prior distribution with a mean of 2.4 and a variance of 0.006
% \beta prior distribution with a mean of 0.07 and a variance of 3e-5
% Noise variance of 0.003

mdl = exponentialDegradationModel('Theta',2.4,'ThetaVariance',0.006,...
                                  'Beta',0.07,'BetaVariance',3e-5,...
                                  'NoiseVariance',0.003);

%
% Since there is no life time variable in the training data, create an arbitrary life time vector for fitting.

lifeTime = [1:length(expRealTime)];

%
% Observe the degradation feature for 100 iterations. Update the degradation model after each iteration.

for i=1:100
    update(mdl,[lifeTime(i) expRealTime(i)])
end

%
% Reset the model, which clears the accumulated statistics from the previous observations and resets the posterior distributions to the prior distributions.

restart(mdl)

% Copyright 2012 The MathWorks, Inc.