Goodness of fit between test and reference data
fit = goodnessOfFit(x,xref,cost_func)
Cost function to determine goodness of fit.
Goodness of fit between test and reference data.
For a single test data set and reference pair,
Obtain the measured output.
load iddata1 z1 yref = z1.y;
z1 is an
iddata object containing measured input/output data.
z1.y is the measured output.
Obtain the estimated output.
sys = tfest(z1,2); y_sim = sim(sys,z1(:,,:));
sys is a second-order transfer function estimated using the measured input/output data.
y is the output estimated using
sys and the measured input.
Calculate the goodness of the fit between the measured and estimated outputs.
cost_func = 'NRMSE'; y = y_sim.y; fit = goodnessOfFit(y,yref,cost_func);
The goodness of fit is calculated using the normalized root mean square error as the cost function.
Alternatively, you can use
to calculate the goodness of fit:
opt = compareOptions('InitialCondition','z'); compare(z1,sys,opt);