On Mar 23, 6:23=A0pm, "Miroslav Balda" <miroslav.nos...@balda.cz> wrote:
> nora12345 <jcoet...@gmail.com> wrote in message
>
> <adcfc16a99b348c495a9c22330e70...@8g2000hsu.googlegroups.com>...
>
>
>
> > hello,
>
> > I am trying to use fminsearch to solve for the paramter
> phee. Whenever
> > I type:
> > phiHat =3D fminsearch(exact(z,x),z,x);
>
> > I get the error message:
>
> > ??? Error using =3D=3D> fcnchk at 105
> > FUN must be a function, a valid string expression,
> > or an inline function object.
>
> > Error in =3D=3D> fminsearch at 178
> > funfcn =3D fcnchk(funfcn,length(varargin));
>
> > my function is defined as:
> > function result =3D exact( h,q)
>
> > % Estimation
> > % =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > x =A0 =A0 =A0 =3D q(:); % should be column vectors !
> > z =A0 =A0 =A0 =3Dh(:);
> > phee =A0 =A0 =3D (inv(x'*x))*(x'*z);
> > N =A0 =A0 =A0 =3D length(x);
> > sig2 =A0 =A0=3D (zphee*x)'*(zphee*x)/N;
> > w =A0 =A0 =A0=3D
>
> (N/2/log(2*pi))+(N/2)*log(sig2)+((zphee*x)'*(zphee*x))/
>
> > 2*sig2;
> > result =3D struct( 'phee',phee);
> > end
>
> > I have no idea what I am doing wrong, any help would be
> welcome!
>
> > Nora
>
> Hi Nora
> As first read help to the function fminsearch. You will read
> there, that the first argument to fminsearch is a handle (or
> name =3D string) of the function to be minimized.
> The second argument is your estimate of the solution. It is
> a strting point of iterations. Then, optional parameters
> controlling iteration process may be set, otherwise default
> parameters are used.
>
> Therefore, you have to call
>
> phiHat =3D fminsearch('exact',[z;x]);
>
> where z and x are initial estimates of a solution, and build
>
> function f =3D exact(p),
> % =A0 your code for the function exact,
>
> where p is a vector of two unknowns, p=3D[z;x].
>
> Hope it helps.
>
> Mira Hide quoted text 
>
>  Show quoted text 
Thanks Mira! I will try that...z and x were my input vectors and I
was trying to solve for phee...does this make a difference?
Nora
