This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Class: NonLinearModel

Evaluate nonlinear regression model prediction


ypred = feval(mdl,Xnew1,Xnew2,...,Xnewn)


ypred = feval(mdl,Xnew1,Xnew2,...,Xnewn) returns the predicted response of mdl to the input [Xnew1,Xnew2,...,Xnewn].

Input Arguments


Nonlinear regression model, constructed by fitnlm.


Predictor components. Xnewi can be one of:

  • Scalar

  • Vector

  • Array

Each nonscalar component must have the same size (number of elements in each dimension).

If you pass just one Xnew array, Xnew can be a table, dataset array, or an array of doubles, where each column of the array represents one predictor.

Output Arguments


Predicted mean values at Xnew. ypred is the same size as each component of Xnew.


expand all

Create a nonlinear model for auto mileage based on the carbig data. Predict the mileage of an average automobile.

Load the data and create a nonlinear model.

load carbig
tbl = table(Horsepower,Weight,MPG);
modelfun = @(b,x)b(1) + b(2)*x(:,1).^b(3) + ...
beta0 = [-50 500 -1 500 -1];
mdl = fitnlm(tbl,modelfun,beta0);

Find the predicted mileage of an average auto. The data contain some observations with NaN, so compute the mean using nanmean.

Xnew = nanmean([Horsepower Weight]);
MPGnew = feval(mdl,Xnew)
MPGnew = 21.8073


predict gives the same predictions, but uses a single input array with one observation in each row, rather than one component in each input argument. predict also gives confidence intervals on its predictions.

random predicts with added noise.