ysim = random(mdl)
ysim = random(mdl,Xnew)
Points at which mdl predicts responses.
Vector of predicted mean values at Xnew, perturbed by random noise. The noise is independent, normally distributed, with mean zero, and variance equal to the estimated error variance of the model.
Create a model of car mileage as a function of weight, and simulate the response.
Create a quadratic model of car mileage as a function of weight from the carsmall data.
load carsmall X = Weight; y = MPG; mdl = fitlm(X,y,'quadratic');
Create simulated responses to the data.
Xnew = X; ysim = random(mdl,Xnew);
Plot the original responses and the simulated responses to see how they differ.