# CE20230 Lecture Notes - Lecture 6: Power Law, Environmental Engineering

14 views3 pages
4 Sep 2016
School
Course
Professor
UNIVERSITY OF NOTRE DAME
Department of Civil and Environmental Engineering
and Earth Sciences
CE 20230 Engineering Programming
A.S. Donahue
Non–Linear Curve Fitting Info
This brief worksheet goes over the details of how we determine the non linear model using the
results of our linear ﬁtting in Matlab. Recall that if we wish to ﬁt a non–linear model to a set of
data our strategy is to ﬁt a linear model to the data after it has been altered in some way, in brief
this looks like:
1. If we wish to ﬁt a Power Law model y=bxmwe ﬁt the following
>> r = polyfit(log(x),log(y),1)
>> y = exp(r(2))*x.^r(1)
we note that the data should look fairly linear on a log–log plot, i.e.
>> loglog(x,y)
2. If we wish to ﬁt an Exponential model y=bemx we ﬁt the following
>> r = polyfit(x,log(y),1)
>> y = exp(r(2))*exp(r(1)*x)
we note that the data should look fairly linear on a semilog–y plot, i.e.
>> semilogy(x,y)
3. If we wish to ﬁt a Logarithmic model y=mln(x) + bwe ﬁt the following
>> r = polyfit(log(x),y,1)
>> y = r(1)*log(x)+r(2)
we note that the data should look fairly linear on a semilog–x plot, i.e.
>> semilogx(x,y)
4. If we wish to ﬁt a Reciprocal model y=1
mx +bwe ﬁt the following
>> r = polyfit(x,1./y,1)
>> y = 1./(r(1)*x+r(2))
we note that the data should look fairly linear on a reciprocal rectilinear plot, i.e.
>> plot(x,1./y)
Note that for plotting we don’t alter the data, we just use a diﬀerent plot command. Its only
when using polyﬁt that we alter the data.
1
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

# Get OneClass Notes+

75% OFF
\$8 USD/m
###### Monthly
\$30 USD/m
You will be charged \$96 USD upfront and auto renewed at the end of each cycle. You may cancel anytime under Payment Settings. For more information, see our Terms and Privacy.