MATLAB function that fits a linear combination of exponential functions to given data

5 次查看(过去 30 天)
Hello,
I have to write a MATLAB function which looks for a linear combination of exponential functions that fits certain given data the best.
The input of the MATLAB function consists of a (n * 2)-matrix and a vector of initial guesses for the exponents. The data has to fit with the following kind of function: f(x) = C_1*e^(lambda_1 * x) + ... + C_m*e^(lambda_m * x)
So the (n * 2)-matrix has n rows and 2 columns. I suppose the left column contains the x_i and the right column contains the y_i for 1 <= i <= n. The magnitude of m depends on the length of the vector with the initial guesses (lambda_1, ..., lambda_m).
The purpose of this MATLAB function is that the function looks for a function f that is the best choice according to the least squares method. In short, a function such that S = \sum_{i=1}^n (y_i - f(x_i))^2 is minimalized.
The output of the MATLAB function exists of twee vectors with the calculated (best) choices for (lambda_1, ..., lamda_m) and (C_1, ..., C_m) en the residue (thus r_i = y_i - f(x_i)). Furthermore, the function has to make a plot of the data and the fit f.
---
I don't have a problem to realize the output, but I do have trouble with determining f. I can use the function fminsearch, so I can use that for the least squares method I guess.
I did get a hint: For fixed lambda = (lambda_1, ..., lambda_m) I should use the least squares method to find the best coefficients C_j = C_j(lambda).
So I think I have to use the initial guesses of lambda as fixed (at first) and 'only' determine the C's. But I don't have a clue how to do this.
Anyone who can help me? Thanks in advance.

回答(1 个)

Image Analyst
Image Analyst 2013-3-15
For a fixed lambda, it's really trivial. Just use the standard least squares formula. Did the course cover that? inverse([A'A]) and so on? Just plug in some range of x and get your e^(lambda*x) array and construct your A matrix.
  5 个评论
Image Analyst
Image Analyst 2013-3-31
I haven't used the fminsearch() function. If that's the way they want you do it, then I am not the best person to help you.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by