Thank you for the reply, I think it is optimal in my case to solve for the p and k independently to using fminsearch! Thanks,
S
"Roger Stafford" wrote in message <k79udt$g69$1@newscl01ah.mathworks.com>...
> "Suyash" wrote in message <k79lb7$gtr$1@newscl01ah.mathworks.com>...
> > Suppose my model is an equation similar to a power function, Y = k.(Ix^p  Th^p) in which, k, p, and Th are constants. I know the values of Ix and corresponding Y. Both Ix and Y are an array. I want to fit my data (Ix ~ Y) with the equation I mentioned earlier (i.e. Y = k.(Ix^p  Th^p) ). How do iterate simultaneously on the values of p and k to find the best leastsquares fit?
>         
> You are given the vectors Ix and Y and the fixed scalar Th and wish to adjust the parameters k and p so as to minimize the quantity
>
> S = sum(k*(Ix.^pTh^p)Y).^2 .
>
> Do I state your problem correctly?
>
> For any given value of p the value of k which minimizes S is
>
> k = sum(Y.*(Ix.^pTh^p))/sum((Ix.^pTh^p).^2)
>
> as one can see by taking the partial derivative of S with respect to k.
>
> By substituting this expression for k one obtains S as a function of the single parameter p. If you know of upper and lower bounds for p, you can then use matlab's 'fminbnd' to find a minimum.
>
> Alternatively you can use 'fminsearch' to find the minimum using either the singlevariable problem with p using the above substitution for k, or the twovariable problem with both p and k as variables. (The singlevariable usage is probably more efficient in this case.)
>
> Roger Stafford
