Homework help.

1 次查看(过去 30 天)
rachel
rachel 2012-4-26
You are given a data set (data2.mat) that must be fit to an equation for your lab assignment. You know that the data has the form y = a *e^bx^c . Find the coefficients a, b and c using a MATLAB function that you have written. Display a plot with a logarithmic y scale that shows the data as points and the line as a fit.
Can anyone help me figure this out. I tried using an exponential function program that used linear regression program in it but that didn't work because it didn't deal with the double power factor. So I really don't know how to go about solving this. I'm in a matlab class for the first time and it's week 3 and he's dropping these sort of things on after not really teaching us how to do this. He clearly knows his stuff but he's very bad at reiterating it to his students so we end up lost all the time. Any help would be great!
here's the data
5.1000000e+001 -9.8614120e+000
4.0800000e+002 -9.3766162e+000
1.3770000e+003 -9.4949558e+000
3.2640000e+003 -9.2442098e+000
6.3750000e+003 -9.0007595e+000
1.1016000e+004 -8.8766913e+000
1.7493000e+004 -9.0074649e+000
2.6112000e+004 -8.9332435e+000
3.7179000e+004 -8.8126032e+000
5.1000000e+004 -8.8844865e+000
6.7881000e+004 -8.7144287e+000
8.8128000e+004 -8.3825442e+000
1.1204700e+005 -8.4576726e+000
1.3994400e+005 -8.5157210e+000
1.7212500e+005 -8.4781113e+000
2.0889600e+005 -8.2878923e+000
2.5056300e+005 -8.3766055e+000
2.9743200e+005 -8.2561491e+000
3.4980900e+005 -8.2137268e+000
4.0800000e+005 -8.0925150e+000
4.7231100e+005 -7.9257422e+000
5.4304800e+005 -7.9381544e+000
6.2051700e+005 -7.9537322e+000
7.0502400e+005 -7.8015010e+000
7.9687500e+005 -7.8356798e+000
8.9637600e+005 -7.6697667e+000
1.0038330e+006 -7.5605739e+000
1.1195520e+006 -7.8521843e+000
1.2438390e+006 -7.6577670e+000
1.3770000e+006 -7.6843260e+000
1.5193410e+006 -7.4819766e+000
1.6711680e+006 -7.4679223e+000
1.8327870e+006 -7.3088850e+000
2.0045040e+006 -7.3311661e+000
2.1866250e+006 -7.2934343e+000
2.3794560e+006 -7.1592624e+000
2.5833030e+006 -7.2461091e+000
2.7984720e+006 -7.0129888e+000
3.0252690e+006 -7.0599327e+000
3.2640000e+006 -6.9684428e+000
3.5149710e+006 -6.7472645e+000
3.7784880e+006 -6.8237334e+000
4.0548570e+006 -6.9460063e+000
4.3443840e+006 -6.8844682e+000
4.6473750e+006 -6.8276870e+000
4.9641360e+006 -6.7922145e+000
5.2949730e+006 -6.8443137e+000
5.6401920e+006 -6.7642609e+000
6.0000990e+006 -6.7283737e+000
6.3750000e+006 -6.5985129e+000
6.7652010e+006 -6.8035724e+000
7.1710080e+006 -6.6019244e+000
7.5927270e+006 -6.5038275e+000
8.0306640e+006 -6.5811262e+000
8.4851250e+006 -6.3259601e+000
8.9564160e+006 -6.6594903e+000
9.4448430e+006 -6.2945521e+000
9.9507120e+006 -6.3241126e+000
1.0474329e+007 -6.2211186e+000
1.1016000e+007 -6.2944763e+000
1.1576031e+007 -6.1571240e+000
1.2154728e+007 -6.0425808e+000
1.2752397e+007 -6.2450068e+000
1.3369344e+007 -6.0584327e+000
1.4005875e+007 -6.0119037e+000
1.4662296e+007 -5.9192135e+000
1.5338913e+007 -6.0227574e+000
1.6036032e+007 -5.9185951e+000
1.6753959e+007 -6.0416041e+000
1.7493000e+007 -5.8492313e+000
1.8253461e+007 -6.0539742e+000
1.9035648e+007 -5.8733411e+000
1.9839867e+007 -5.8752898e+000
2.0666424e+007 -5.7343361e+000
2.1515625e+007 -5.8322730e+000
2.2387776e+007 -5.7831574e+000
2.3283183e+007 -5.5679345e+000
2.4202152e+007 -5.6356530e+000
2.5144989e+007 -5.7559464e+000
2.6112000e+007 -5.7025321e+000
2.7103491e+007 -5.6388418e+000
2.8119768e+007 -5.6041841e+000
2.9161137e+007 -5.4867117e+000
3.0227904e+007 -5.4993242e+000
3.1320375e+007 -5.6516519e+000
3.2438856e+007 -5.4882504e+000
3.3583653e+007 -5.5297368e+000
3.4755072e+007 -5.3379112e+000
3.5953419e+007 -5.2417512e+000
3.7179000e+007 -5.1143483e+000
3.8432121e+007 -5.2538556e+000
3.9713088e+007 -5.2262771e+000
4.1022207e+007 -5.1662034e+000
4.2359784e+007 -5.2907350e+000
4.3726125e+007 -5.1033225e+000
4.5121536e+007 -5.0992933e+000
4.6546323e+007 -5.2062895e+000
4.8000792e+007 -5.1410342e+000
4.9485249e+007 -5.0594874e+000
5.1000000e+007 -5.1098396e+000
  6 个评论
Walter Roberson
Walter Roberson 2012-4-27
In that case you will not be able to find a unique answer.
If you consider
a * e^b * x^c
then for every 1 that "b" increases, if you decrease "a" by a factor of "e", then the numeric result will be the same. (a*exp(b)) effectively becomes a single constant and you cannot separate the effect of "a" and "b" -- not unless you have a bunch of constraints that force the constant to be broken down a particular way.
Image Analyst
Image Analyst 2012-4-27
Just to further explain what Walter is saying:
y = a * exp(b) * x^c <== your original equation.
log(y) = log(a) + log(exp(b) + * log(x^c)
log(y) = log(a) + b + c * log(x)
newY = c2 + c1 * newX
with c1 being equal to c, and c2 being equal to log(a)+b.
So now you have two coefficients you can use polyfit to solve for.
But there are lots of combinations of a and b that might give c2.
So no unique solution, at least if you use linear regression.

请先登录,再进行评论。

回答(3 个)

Sean de Wolski
Sean de Wolski 2012-4-26
doc semilogy
doc lsqcruvefit
doc nlinfit
Some places to look...
  1 个评论
rachel
rachel 2012-4-27
our professor did mention semilogy but even after plotting the data and using that function it's not a straight line (which is the goal) and it doesn't help me solve for any of the unknowns (a,b,and c). I'm just overall confused.

请先登录,再进行评论。


Richard Willey
Richard Willey 2012-4-26
Couple quick questions / comments
1. are you sure you typed in the model correctly? This looks very close to a Gompertz function (however some terms are missing)
2. The following example on the Statistics Toolbox page address should give you some useful ideas as to different approaches to solve this problem
  1 个评论
rachel
rachel 2012-4-27
I looked at the link but I got a bit confused as to what I use as p.. also because I have 3 variables I get confused as well. I've never heard of the Gompertz function but perhaps I'll look into that. I'm really brand new to matlab and don't know at all what I'm doing yet.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2012-4-27
Your expression simplifies to y = d * x^b for unknown values "d" and "b" and x known. log() both sides to get
log(y) = log(d) + b * ln(x)
and then this becomes a linear regression.
  3 个评论
Walter Roberson
Walter Roberson 2012-4-27
Right, this is an explication of how you would proceed after wrapping the variables together, but you cannot separate "a" and "b".
My suspicion is that the expression to fit against was not given to us correctly.
Image Analyst
Image Analyst 2012-4-27
Well I don't know that much about fitting. So it's not possible with linear regression, but would it be possible to get all three unknowns with a more sophisticated, non-linear type of fitting routine? I suspect so. Maybe in class the prof talked about the proper type of fitting algorithm for her to use???

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by