More generally, to create a linear regression model, use the fitlm() function. This function creates a LinearModel object. The object in the workspace has a series of properties that can be immediately viewed by simply clicking on it. Methods such as plot, plotResiduals, and plotDiagnostics are available if you want to create plots and perform a diagnostic analysis.
LinearModel is an object comprising training data, model description, diagnostic information, and fitted coefficients for a linear regression.
By default, fitlm() takes the last variable in the table or dataset array as the response. Otherwise, we have to specify predictors and response variables, for example, as a formula. In addition, we can set a specific column as the response variable by using the ResponseVar name-value pair argument. To use a set of the columns as predictors...