Simulate responses for linear regression model
ysim = random(mdl)
ysim = random(mdl,Xnew)
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
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.
Usage notes and limitations:
codegen to generate code for the
random function. Save a trained model by using
saveCompactModel and define an entry-point function that loads the saved model
loadCompactModel and calls the
random function. Then use
codegen to generate code for the entry-point function.
If either of the following is true, then
return a different sequence of numbers than MATLAB®.
The output is nonscalar.
An input parameter is invalid for the distribution.
This table contains
notes about arguments of
|Argument||Notes and Limitations|
For more information, see Introduction to Code Generation.