Goodness of fit between test and reference data
fit = goodnessOfFit(x,xref,cost_func)
x is an Ns-by-N matrix, where Ns is the number of samples and N is the number of channels.
x can also be a cell array of multiple test data sets.
x must not contain any NaN or Inf values.
xref must be of the same size as x.
xref can also be a cell array of multiple reference sets. In this case, each individual reference set must be of the same size as the corresponding test data set.
xref must not contain any NaN or Inf values.
Cost function to determine goodness of fit.
cost_func must be one of the following strings:
Goodness of fit between test and reference data.
For a single test data set and reference pair, fit is returned as a:
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 compare to calculate the goodness of fit:
opt = compareOptions('InitialCondition','z'); compare(z1,sys,opt);