plot linear regression matlab

Get Matlab Help Now..!

MATLAB Assignment Help by MATLAB Programming Expert

Linear regression is a statistical modeling methods used to describe a continuous response variable as a function of one or more predictor variables. It can help users to understand and predict the behavior of complex systems or analyze financial, experimental and biological data.

Linear regression methods are used to make a linear model. The model defines the relationship between a dependent variable y(also called the response) as a function of one or more independent variables Xi (called the predictors). Here is a general equation for linear regression model:

where β represents linear parameter estimates to be computed and ϵ represents the error terms.

There are several types of linear regression models:

  • • Simple: model with only one predictor

  • • Multiple: model with multiple predictors

  • • Multivariate: model for multiple response variables

MATLAB provides these function for plotting the linear regression

  • • plotregression(targets,outputs)

  • • plotregression(targs1,outs1,'name1',targs2,outs2,'name2',...)

plotregression(targets,outputs) plots the linear regression of targets with respect to outputs.

plotregression(targs1,outs1,'name1',targs2,outs2,'name2',...) generates multiple plots.

Here is an example which helps to better understand the concept of linear regression plotting in MATLAB. This example show the usage of plotting functions available in MATLAB

Plot Linear Regression

[x,t] = simplefit_dataset;

net = feedforwardnet(10);

net = train(net,x,t);

y = net(x);


The linear regression plot shown below