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

조회 수: 4 (최근 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.
Tom
Tom 2013년 3월 31일
It is not necessary to use that approach, but they only gave it as a hint.

댓글을 달려면 로그인하십시오.

카테고리

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