Implementation of a function
- From: Maniaoh <n.hoainam@xxxxxxxxx>
- Date: Tue, 19 Aug 2008 21:16:23 -0700 (PDT)
Hi,
I would like to ask a question about implementation of a function in
Matlab. Let me explain my question:
In my problem, it is necessary to define a fuction in the form:
f(t) = a*exp(bt)
in which a and b can be analytically expressed as a = a_1*s + a_2*n
and b = b_1*s +b_2*n where s, n are arrays of known integer values.
(For example, a = 1:3 and b = 1:5.)
We have f(a, b, t) = (a_1*s + a_2*n)*exp[(b_1*s +b_2*n)*t]. I want to
fit the function to some observed data so I have to minimize the sum
of square.
We'll take a mechanism as follow. Let's consider the trivial case,
where a and b are number themselves (not analytical expressions), it
is easy to define f(t) as:
func = @(x, theta) theta1*exp(theta2*t) (1)
and the sum of square is illustated in the following form:
ssfunc = @(theta, data) sum((data.ydata - func(data.xdata,
theta)).^2) (2)
Using
[thetaHat, ssmin] = fminsearch(ssfunc, initialValues, [],
data) (3)
it is possible to find the minimum value for ssfunc as well as the
corresponding parameters theta1 & theta2.
The question is: how can I use the same mechanism (1, 2, 3) to find
thetaHat when a, b are expressed in its full form. In this case,
thetaHat = [thetaHat1 thetaHat2 thetaHat3 thetaHat4] where
thetaHat1, 2 = a_1, 2 and thetaHat3, 4 = b_1, 2.
The question can be understood in other way as well, "how to implement
f(t) and use it for sum of square minimization?".
Any comment from you is greatly appreciated.
I am looking forward to seeing your replies,
Iaoh.
.
- Prev by Date: Re: C++ Matrix & Linear Algebra library
- Next by Date: Re: ? tensor diff
- Previous by thread: Re: SOLUTION MANUALS
- Next by thread: Excel's XIRR function
- Index(es):
Relevant Pages
|