www.gusucode.com > stats 源码程序 matlab案例代码 > stats/PlotAdjustedResponsesExample.m
%% Plot Adjusted Responses % Plot the adjusted responses of a fitted linear model. %% % Load the |carsmall| data and fit a linear model of the mileage as a function % of model year, weight, and weight squared. load carsmall tbl = table(MPG,Weight); tbl.Year = categorical(Model_Year); mdl = fitlm(tbl,'MPG ~ Year + Weight^2'); %% % Plot the effect of |'Weight'| averaged over |Year| values. plotAdjustedResponse(mdl,'Weight') %% % Plot the effect of |Year| averaged over |'Weight'| values. Include the % |h| output. h = plotAdjustedResponse(mdl,'Year'); %% % Change the adjusted data to black |x| instead of red |o|. h(1).Marker = 'x'; h(1).Color = 'k';