www.gusucode.com > stats 源码程序 matlab案例代码 > stats/SimulateResponseDataFromLinearRegressionModelExample.m
%% Simulate Response Data From Linear Regression 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. plot(X,y,'o',X,ysim,'x') legend('Data','Simulated')