> Dear comrades, > I am trying to solve the problem on resolving the > mixture of two exponents. > The data I measure comes in the plot Y(response > measured from the system) over t (time). > The task I have formulated sounds like this: > Minimize ||yhat(c,t)-y||; > where yhat = c(3)*exp(-t*c(1)) + c(4)*exp(-t*c(2)) > subject to > c(1-4)>=1 and c(3)+c(4)=1. > > Here are my attempts in solving it (2 in total): > > (1)With the use of Optimization Toolbox: > close all, clear all > t = [0 .3 .8 1.1 1.6 2.3]'; > y = [.82 .72 .63 .60 .55 .50]'; > plot(t,y,'o') > yhat = @(c,t) c(3)*exp(-t*c(1)) + c(4)*exp(-t*c(2)); > > c0=[0.5; 0.5; 2; 30] > c = fmincon(@(c)yhat(c,t)-y, c0, [1,1,1,1], 0, > [0,0,1,1], 1, ,) > I receive an error: > ??? Error using ==> fmincon at 647 > User supplied objective function must return a scalar > value. > > (2) With the use of MATLAB Package bayesf > http://statmath.wu.ac.at/~fruehwirth/monographie/ > Demo_mix_exponential.m in particular > Here I fail to plug my data into the problem. Am > sorry for perhaps a tedious question, but am really a > nub that found no solution for the problem so far. > > I am greatly thankful for your suggestions and help.
The call to fmincon has to look like c = fmincon(@(c)(yhat(c,t)-y)'*(yhat(c,t)-y), c0, [1,1,1,1], 0, [0,0,1,1], 1, ,)