www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CompactALinearRegressionModelExample.m
%% Compact a Linear Regression Model % This example shows how to reduce the size of a full, fitted linear % regression model by discarding the sample data and some information % related to the fitting process. %% % Load the data into the workspace. load(fullfile(matlabroot,'examples','stats','largedata4reg.mat')) %% % The simulated sample data contains 15,000 observations and 45 predictor % variables. %% % Fit a simple linear regression model to the data. mdl = fitlm(X,Y) %% % Compact the model. compactMdl = compact(mdl) %% % The compact model discards the original sample data and some information % related to the fitting process. %% % Compare the size of the full model |mdl| and the compact model % |compactMdl|. vars = whos('compactMdl','mdl'); [vars(1).bytes,vars(2).bytes] %% % The compacted model consumes less memory than the full model.