# Regression analysis

 Page 1 / 1
Basic curve fitting and linear regression.

## What is regression analysis?

Suppose we calculate some variable of interest, y, as a function of some other variable x. We call y the dependent variable and x the independent variable. For example, consider the data set below, taken from a simple experiment involving a vehicle, its velocity versus time is tabulated. In this case, velocity is a function of time, thus velocity is the dependent variable and the time is the independent variable.

Time [s] Velocity [m/s]
0 20
10 39
20 67
30 89
40 111
50 134
60 164
70 180
80 200

In its simplest form regression analysis involves fitting the best straight line relationship to explain how the variation in a dependent variable, y, depends on the variation in an independent variable, x. In our example above, once the relationship (in this case a linear relationship) has been estimated we can produce a linear equation in the following form:

$y=mx+n$

And once an analytic equation such as the one above has been determined, dependent variables at intermediate independent values can be computed.

## Performing linear regression

Regression analysis with MATLAB is easy. The MATLAB Basic Fitting GUI allows us to interactively to do "curve fitting" which is a method to arrive at the best "straight line" fit for linear equations or the best curve fit for a polynomial up to the tenth degree. The procedure to perform a curve fitting with MATLAB is as follows:

1. Input the variables,
2. Plot the data,
3. Initialize the Basic Fitting GUI,
4. Select the desired regression analysis parameters.

Using the data set above, determine the relationship between velocity and time.

First, let us input the variables (Workspace>New variable) as shown in the following figures.

Second, we will plot the data by typing in plot(time,velocity) at the MATLAB prompt. The following plot is generated, select Tools>Basic Fitting:

In the "Basic Fitting" window, select "linear" and "Show equations". The best fitting linear line along with the corresponding equation are displayed on the plot:

Now let us do another curve fitting and obtain an equation for the function. Using that equation, we can evaluate the function at a desired value with polyval .

The following is a collection of data for an iron-constantan thermocouple (data available for download ). Engineering Fundamentals and Problem Solving by Arvid R. Eide, Roland Jenison, Larry L. Northup, Steven K. Mikelson , McGraw-Hill Higher Education. © 2007 p.114

Temperature [C] Voltage [mV]
50 2.6
100 6.7
150 8.8
200 11.2
300 17.0
400 22.5
500 26
600 32.5
700 37.7
800 41
900 48
1000 55.2
1. Plot a graph with Temperature as the independent variable.
2. Determine the equation of the relationship using the Basic Fitting tools.
3. Estimate the Voltage that corresponds to a Temperature of 650 C and 1150 C.

We will input the variables first:

Temp=[50;100;150;200;300;400;500;600;700;800;900;1000] Voltage=[2.6;6.7;8.8;11.2;17;22.5;26;32.5;37.7;41;48;55.2]

To plot the graph, type in:

plot(Temp,Voltage)

We can now use the Plot Tools and Basic Fitting settings and determine the equation:

By clicking the right arrow twice at the bottom right corner on the Basic Fitting window, we can evaluate the function at a desired value. See the figure below which illustrates this process for the temperature value 1150 C.

Now let us check our answer with a technique we learned earlier. As displayed on the plot, we have obtained the following equation: $y=\mathrm{0.052831}x+\mathrm{0.67202}$ This equation can be entered as polynomial and evaluated at 650 and 1150 as follows:

>>p=[0.052831,0.67202] p =0.0528 0.6720>>polyval(p,1150) ans =61.4277

## Summary of key points

1. Linear regression involves fitting the best straight line relationship to explain how the variation in a dependent variable, y, depends on the variation in an independent variable, x,
2. Basic Fitting GUI allows us to interactively perform curve fitting,
3. Some of the plot fits available are linear, quadratic and cubic functions,
4. Basic Fitting GUI can evaluate functions at given points.

#### Questions & Answers

where we get a research paper on Nano chemistry....?
what are the products of Nano chemistry?
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
Preparation and Applications of Nanomaterial for Drug Delivery
revolt
da
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
I only see partial conversation and what's the question here!
what about nanotechnology for water purification
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
why we need to study biomolecules, molecular biology in nanotechnology?
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
why?
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!