Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Fminsearch with matrix as an input

Subject: Fminsearch with matrix as an input

From: Saad

Date: 11 Aug, 2011 18:06:27

Message: 1 of 9

Dear all,

I would like to minimize a function called "cal4" (please see below) that is function of a matrix H. I would like to do the minimization by changing the matrix H ( 7 by 7). When I write the code:

%%%%%%%%%%%%%%%%%%%%%%%%%
start0=eye(7);

g= fminsearch(@(H)cal4(H), start0);
 
I get the following error message:
??? Subscripted assignment dimension mismatch.

Error in ==> fminsearch at 205
fv(:,1) = funfcn(x,varargin{:});

Error in ==> cal5 at 106
g= fminsearch(@(H)cal4(H), start0);
 
Any ideas where the problem is? I dont understand why there is a dimension mismatch because the output of "cal4" is also 7 by 7 matrix. Sorry I can not copy cal4 because the function is quite long but I am happy to clarify further if necessary.


Now I also would like to minimize "cal4" by only changing some elements of the matrix (not the whole matrix because I would like to the diagonals to be equal to 1 all the time) .

How I can do that using fminsearch? I tried something like

g= fminsearch(@(H(2,1))cal4(H), 0.1) but matlab does not accept that.....

Any help or suggestion is welcomed. Thank you very much

Best Regards

S

Subject: Fminsearch with matrix as an input

From: Alan Weiss

Date: 11 Aug, 2011 18:10:00

Message: 2 of 9

On 8/11/2011 2:06 PM, Saad wrote:
> Dear all,
>
> I would like to minimize a function called "cal4" (please see below)
> that is function of a matrix H. I would like to do the minimization by
> changing the matrix H ( 7 by 7). When I write the code:
>
> %%%%%%%%%%%%%%%%%%%%%%%%%
> start0=eye(7);
>
> g= fminsearch(@(H)cal4(H), start0);
>
> I get the following error message: ??? Subscripted assignment dimension
> mismatch.
>
> Error in ==> fminsearch at 205
> fv(:,1) = funfcn(x,varargin{:});
>
> Error in ==> cal5 at 106
> g= fminsearch(@(H)cal4(H), start0);
>
> Any ideas where the problem is? I dont understand why there is a
> dimension mismatch because the output of "cal4" is also 7 by 7 matrix.
> Sorry I can not copy cal4 because the function is quite long but I am
> happy to clarify further if necessary.
>
>
> Now I also would like to minimize "cal4" by only changing some elements
> of the matrix (not the whole matrix because I would like to the
> diagonals to be equal to 1 all the time) .
>
> How I can do that using fminsearch? I tried something like
> g= fminsearch(@(H(2,1))cal4(H), 0.1) but matlab does not accept that.....
>
> Any help or suggestion is welcomed. Thank you very much
>
> Best Regards
>
> S

See the answers in this thread:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/311442

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: Fminsearch with matrix as an input

From: Saad

Date: 12 Aug, 2011 09:29:10

Message: 3 of 9

Alan Weiss <aweiss@mathworks.com> wrote in message <j215to$mrj$1@newscl01ah.mathworks.com>...
> On 8/11/2011 2:06 PM, Saad wrote:
> > Dear all,
> >
> > I would like to minimize a function called "cal4" (please see below)
> > that is function of a matrix H. I would like to do the minimization by
> > changing the matrix H ( 7 by 7). When I write the code:
> >
> > %%%%%%%%%%%%%%%%%%%%%%%%%
> > start0=eye(7);
> >
> > g= fminsearch(@(H)cal4(H), start0);
> >
> > I get the following error message: ??? Subscripted assignment dimension
> > mismatch.
> >
> > Error in ==> fminsearch at 205
> > fv(:,1) = funfcn(x,varargin{:});
> >
> > Error in ==> cal5 at 106
> > g= fminsearch(@(H)cal4(H), start0);
> >
> > Any ideas where the problem is? I dont understand why there is a
> > dimension mismatch because the output of "cal4" is also 7 by 7 matrix.
> > Sorry I can not copy cal4 because the function is quite long but I am
> > happy to clarify further if necessary.
> >
> >
> > Now I also would like to minimize "cal4" by only changing some elements
> > of the matrix (not the whole matrix because I would like to the
> > diagonals to be equal to 1 all the time) .
> >
> > How I can do that using fminsearch? I tried something like
> > g= fminsearch(@(H(2,1))cal4(H), 0.1) but matlab does not accept that.....
> >
> > Any help or suggestion is welcomed. Thank you very much
> >
> > Best Regards
> >
> > S
>
> See the answers in this thread:
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/311442
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

Hi Alan

Thank you very much for your help on this. I set up the matrix just like you said. Actually my issue is slightly more involved than this (sorry this is going to be a bit long).

I am trying the minimize the following function "cal6":

%%%%File 1%%%%%%%%%%%%%%%%%%%%%%%

function M= cal6(X,n)

%%% some constants
n_ask=n;

H= [1 X(1) X(2) ; X(3) 1 X(4) ; X(5) X(6) 1 ];

P= cal4(H,n);

%% As you can see one of the input of "cal6" is P and the same P is the output of %%another function (P in my case is a 'n by n' matrix)

%% M is the output of "cal6" that minimizes the difference btw variance of the %% second column of P and some constant n_ask
%% M is a scalar

 M=(var(P(:,2))-n_ask^2)^2;

%%%%%%%%%%%File 2%%%%%%%%%%%%%%

%% I create another file where I call the function "cal6" to minimize
n_ask=0.5;
start_X=zeros(1,6);
  
  g= fminsearch(@(X)cal6(X, n), start_X)

 %%%
Now as I said I am trying to minimize "cal6" by changing "H". and I would like to use the new estimate of "H" as new input "cal4" and minimize again "cal6" and keep repeating the operation until the norm of "H_new" minus "H_old" is smaller than 0.01. My questions are:

IS this repeating process done automatically by fminsearch? How I can stop the iteration when the norm of the difference is smaller than 0.01? Finally, is there any other way to write my code in an efficient way?

Thank you very much for your advice on this.

Best Regards

S

Subject: Fminsearch with matrix as an input

From: Alan Weiss

Date: 12 Aug, 2011 12:42:54

Message: 4 of 9

On 8/12/2011 5:29 AM, Saad wrote:
> Alan Weiss <aweiss@mathworks.com> wrote in message
> <j215to$mrj$1@newscl01ah.mathworks.com>...
>> On 8/11/2011 2:06 PM, Saad wrote:
>> > Dear all,
>> >
>> > I would like to minimize a function called "cal4" (please see below)
>> > that is function of a matrix H. I would like to do the minimization by
>> > changing the matrix H ( 7 by 7). When I write the code:
>> >
>> > %%%%%%%%%%%%%%%%%%%%%%%%%
>> > start0=eye(7);
>> >
>> > g= fminsearch(@(H)cal4(H), start0);
>> >
>> > I get the following error message: ??? Subscripted assignment dimension
>> > mismatch.
>> >
>> > Error in ==> fminsearch at 205
>> > fv(:,1) = funfcn(x,varargin{:});
>> >
>> > Error in ==> cal5 at 106
>> > g= fminsearch(@(H)cal4(H), start0);
>> >
>> > Any ideas where the problem is? I dont understand why there is a
>> > dimension mismatch because the output of "cal4" is also 7 by 7 matrix.
>> > Sorry I can not copy cal4 because the function is quite long but I am
>> > happy to clarify further if necessary.
>> >
>> >
>> > Now I also would like to minimize "cal4" by only changing some elements
>> > of the matrix (not the whole matrix because I would like to the
>> > diagonals to be equal to 1 all the time) .
>> >
>> > How I can do that using fminsearch? I tried something like
>> > g= fminsearch(@(H(2,1))cal4(H), 0.1) but matlab does not accept
>> that.....
>> >
>> > Any help or suggestion is welcomed. Thank you very much
>> >
>> > Best Regards
>> >
>> > S
>>
>> See the answers in this thread:
>> http://www.mathworks.com/matlabcentral/newsreader/view_thread/311442
>>
>> Alan Weiss
>> MATLAB mathematical toolbox documentation
>
> Hi Alan
>
> Thank you very much for your help on this. I set up the matrix just like
> you said. Actually my issue is slightly more involved than this (sorry
> this is going to be a bit long).
>
> I am trying the minimize the following function "cal6":
>
> %%%%File 1%%%%%%%%%%%%%%%%%%%%%%%
>
> function M= cal6(X,n)
>
> %%% some constants
> n_ask=n;
>
> H= [1 X(1) X(2) ; X(3) 1 X(4) ; X(5) X(6) 1 ];
>
> P= cal4(H,n);
>
> %% As you can see one of the input of "cal6" is P and the same P is the
> output of %%another function (P in my case is a 'n by n' matrix)
>
> %% M is the output of "cal6" that minimizes the difference btw variance
> of the %% second column of P and some constant n_ask
> %% M is a scalar
>
> M=(var(P(:,2))-n_ask^2)^2;
>
> %%%%%%%%%%%File 2%%%%%%%%%%%%%%
>
> %% I create another file where I call the function "cal6" to minimize
> n_ask=0.5; start_X=zeros(1,6);
>
> g= fminsearch(@(X)cal6(X, n), start_X)
>
> %%%
> Now as I said I am trying to minimize "cal6" by changing "H". and I
> would like to use the new estimate of "H" as new input "cal4" and
> minimize again "cal6" and keep repeating the operation until the norm of
> "H_new" minus "H_old" is smaller than 0.01. My questions are:
>
> IS this repeating process done automatically by fminsearch? How I can
> stop the iteration when the norm of the difference is smaller than 0.01?
> Finally, is there any other way to write my code in an efficient way?
>
> Thank you very much for your advice on this.
>
> Best Regards
>
> S

To answer your second question first:
As explained in the documentation
http://www.mathworks.com/help/techdoc/math/bsgpq6p-17.html
you can set the TolFun option to 1e-2 to stop the iterations when the
difference between successive evaluations is less than 1e-2 (similar,
but not exactly the same as what you asked). You can also set an output
function
http://www.mathworks.com/help/techdoc/math/bsgpq6p-23.html
to stop the iterations according to your criterion. In particular, see
http://www.mathworks.com/help/techdoc/math/bsgpq6p-23.html#bsgpq6q-39

For your first question:
You do not need to perform iterations manually. Your cal6 function calls
cal4, and fminsearch tries to minimize cal6, which is (I think) what you
want.

I don't see any obvious way to make your code more efficient, except
perhaps by passing in some options such as a different TolFun or an
output function. It strikes me that there might not be a unique minimum
to your problem, but I could be wrong.

Good luck,

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: Fminsearch with matrix as an input

From: Saad

Date: 12 Aug, 2011 13:29:13

Message: 5 of 9

Alan Weiss <aweiss@mathworks.com> wrote in message <j2374e$5a4$1@newscl01ah.mathworks.com>...
> On 8/12/2011 5:29 AM, Saad wrote:
> > Alan Weiss <aweiss@mathworks.com> wrote in message
> > <j215to$mrj$1@newscl01ah.mathworks.com>...
> >> On 8/11/2011 2:06 PM, Saad wrote:
> >> > Dear all,
> >> >
> >> > I would like to minimize a function called "cal4" (please see below)
> >> > that is function of a matrix H. I would like to do the minimization by
> >> > changing the matrix H ( 7 by 7). When I write the code:
> >> >
> >> > %%%%%%%%%%%%%%%%%%%%%%%%%
> >> > start0=eye(7);
> >> >
> >> > g= fminsearch(@(H)cal4(H), start0);
> >> >
> >> > I get the following error message: ??? Subscripted assignment dimension
> >> > mismatch.
> >> >
> >> > Error in ==> fminsearch at 205
> >> > fv(:,1) = funfcn(x,varargin{:});
> >> >
> >> > Error in ==> cal5 at 106
> >> > g= fminsearch(@(H)cal4(H), start0);
> >> >
> >> > Any ideas where the problem is? I dont understand why there is a
> >> > dimension mismatch because the output of "cal4" is also 7 by 7 matrix.
> >> > Sorry I can not copy cal4 because the function is quite long but I am
> >> > happy to clarify further if necessary.
> >> >
> >> >
> >> > Now I also would like to minimize "cal4" by only changing some elements
> >> > of the matrix (not the whole matrix because I would like to the
> >> > diagonals to be equal to 1 all the time) .
> >> >
> >> > How I can do that using fminsearch? I tried something like
> >> > g= fminsearch(@(H(2,1))cal4(H), 0.1) but matlab does not accept
> >> that.....
> >> >
> >> > Any help or suggestion is welcomed. Thank you very much
> >> >
> >> > Best Regards
> >> >
> >> > S
> >>
> >> See the answers in this thread:
> >> http://www.mathworks.com/matlabcentral/newsreader/view_thread/311442
> >>
> >> Alan Weiss
> >> MATLAB mathematical toolbox documentation
> >
> > Hi Alan
> >
> > Thank you very much for your help on this. I set up the matrix just like
> > you said. Actually my issue is slightly more involved than this (sorry
> > this is going to be a bit long).
> >
> > I am trying the minimize the following function "cal6":
> >
> > %%%%File 1%%%%%%%%%%%%%%%%%%%%%%%
> >
> > function M= cal6(X,n)
> >
> > %%% some constants
> > n_ask=n;
> >
> > H= [1 X(1) X(2) ; X(3) 1 X(4) ; X(5) X(6) 1 ];
> >
> > P= cal4(H,n);
> >
> > %% As you can see one of the input of "cal6" is P and the same P is the
> > output of %%another function (P in my case is a 'n by n' matrix)
> >
> > %% M is the output of "cal6" that minimizes the difference btw variance
> > of the %% second column of P and some constant n_ask
> > %% M is a scalar
> >
> > M=(var(P(:,2))-n_ask^2)^2;
> >
> > %%%%%%%%%%%File 2%%%%%%%%%%%%%%
> >
> > %% I create another file where I call the function "cal6" to minimize
> > n_ask=0.5; start_X=zeros(1,6);
> >
> > g= fminsearch(@(X)cal6(X, n), start_X)
> >
> > %%%
> > Now as I said I am trying to minimize "cal6" by changing "H". and I
> > would like to use the new estimate of "H" as new input "cal4" and
> > minimize again "cal6" and keep repeating the operation until the norm of
> > "H_new" minus "H_old" is smaller than 0.01. My questions are:
> >
> > IS this repeating process done automatically by fminsearch? How I can
> > stop the iteration when the norm of the difference is smaller than 0.01?
> > Finally, is there any other way to write my code in an efficient way?
> >
> > Thank you very much for your advice on this.
> >
> > Best Regards
> >
> > S
>
> To answer your second question first:
> As explained in the documentation
> http://www.mathworks.com/help/techdoc/math/bsgpq6p-17.html
> you can set the TolFun option to 1e-2 to stop the iterations when the
> difference between successive evaluations is less than 1e-2 (similar,
> but not exactly the same as what you asked). You can also set an output
> function
> http://www.mathworks.com/help/techdoc/math/bsgpq6p-23.html
> to stop the iterations according to your criterion. In particular, see
> http://www.mathworks.com/help/techdoc/math/bsgpq6p-23.html#bsgpq6q-39
>
> For your first question:
> You do not need to perform iterations manually. Your cal6 function calls
> cal4, and fminsearch tries to minimize cal6, which is (I think) what you
> want.
>
> I don't see any obvious way to make your code more efficient, except
> perhaps by passing in some options such as a different TolFun or an
> output function. It strikes me that there might not be a unique minimum
> to your problem, but I could be wrong.
>
> Good luck,
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

Hi Alan

Thank you for your quick reply. The constraint that I would like to impose is on the input "H" not the function value "cal6" (which is the function I am trying to minimize)

Subject: Fminsearch with matrix as an input

From: Saad

Date: 12 Aug, 2011 13:37:11

Message: 6 of 9

Alan Weiss <aweiss@mathworks.com> wrote in message <j2374e$5a4$1@newscl01ah.mathworks.com>...
> On 8/12/2011 5:29 AM, Saad wrote:
> > Alan Weiss <aweiss@mathworks.com> wrote in message
> > <j215to$mrj$1@newscl01ah.mathworks.com>...
> >> On 8/11/2011 2:06 PM, Saad wrote:
> >> > Dear all,
> >> >
> >> > I would like to minimize a function called "cal4" (please see below)
> >> > that is function of a matrix H. I would like to do the minimization by
> >> > changing the matrix H ( 7 by 7). When I write the code:
> >> >
> >> > %%%%%%%%%%%%%%%%%%%%%%%%%
> >> > start0=eye(7);
> >> >
> >> > g= fminsearch(@(H)cal4(H), start0);
> >> >
> >> > I get the following error message: ??? Subscripted assignment dimension
> >> > mismatch.
> >> >
> >> > Error in ==> fminsearch at 205
> >> > fv(:,1) = funfcn(x,varargin{:});
> >> >
> >> > Error in ==> cal5 at 106
> >> > g= fminsearch(@(H)cal4(H), start0);
> >> >
> >> > Any ideas where the problem is? I dont understand why there is a
> >> > dimension mismatch because the output of "cal4" is also 7 by 7 matrix.
> >> > Sorry I can not copy cal4 because the function is quite long but I am
> >> > happy to clarify further if necessary.
> >> >
> >> >
> >> > Now I also would like to minimize "cal4" by only changing some elements
> >> > of the matrix (not the whole matrix because I would like to the
> >> > diagonals to be equal to 1 all the time) .
> >> >
> >> > How I can do that using fminsearch? I tried something like
> >> > g= fminsearch(@(H(2,1))cal4(H), 0.1) but matlab does not accept
> >> that.....
> >> >
> >> > Any help or suggestion is welcomed. Thank you very much
> >> >
> >> > Best Regards
> >> >
> >> > S
> >>
> >> See the answers in this thread:
> >> http://www.mathworks.com/matlabcentral/newsreader/view_thread/311442
> >>
> >> Alan Weiss
> >> MATLAB mathematical toolbox documentation
> >
> > Hi Alan
> >
> > Thank you very much for your help on this. I set up the matrix just like
> > you said. Actually my issue is slightly more involved than this (sorry
> > this is going to be a bit long).
> >
> > I am trying the minimize the following function "cal6":
> >
> > %%%%File 1%%%%%%%%%%%%%%%%%%%%%%%
> >
> > function M= cal6(X,n)
> >
> > %%% some constants
> > n_ask=n;
> >
> > H= [1 X(1) X(2) ; X(3) 1 X(4) ; X(5) X(6) 1 ];
> >
> > P= cal4(H,n);
> >
> > %% As you can see one of the input of "cal6" is P and the same P is the
> > output of %%another function (P in my case is a 'n by n' matrix)
> >
> > %% M is the output of "cal6" that minimizes the difference btw variance
> > of the %% second column of P and some constant n_ask
> > %% M is a scalar
> >
> > M=(var(P(:,2))-n_ask^2)^2;
> >
> > %%%%%%%%%%%File 2%%%%%%%%%%%%%%
> >
> > %% I create another file where I call the function "cal6" to minimize
> > n_ask=0.5; start_X=zeros(1,6);
> >
> > g= fminsearch(@(X)cal6(X, n), start_X)
> >
> > %%%
> > Now as I said I am trying to minimize "cal6" by changing "H". and I
> > would like to use the new estimate of "H" as new input "cal4" and
> > minimize again "cal6" and keep repeating the operation until the norm of
> > "H_new" minus "H_old" is smaller than 0.01. My questions are:
> >
> > IS this repeating process done automatically by fminsearch? How I can
> > stop the iteration when the norm of the difference is smaller than 0.01?
> > Finally, is there any other way to write my code in an efficient way?
> >
> > Thank you very much for your advice on this.
> >
> > Best Regards
> >
> > S
>
> To answer your second question first:
> As explained in the documentation
> http://www.mathworks.com/help/techdoc/math/bsgpq6p-17.html
> you can set the TolFun option to 1e-2 to stop the iterations when the
> difference between successive evaluations is less than 1e-2 (similar,
> but not exactly the same as what you asked). You can also set an output
> function
> http://www.mathworks.com/help/techdoc/math/bsgpq6p-23.html
> to stop the iterations according to your criterion. In particular, see
> http://www.mathworks.com/help/techdoc/math/bsgpq6p-23.html#bsgpq6q-39
>
> For your first question:
> You do not need to perform iterations manually. Your cal6 function calls
> cal4, and fminsearch tries to minimize cal6, which is (I think) what you
> want.
>
> I don't see any obvious way to make your code more efficient, except
> perhaps by passing in some options such as a different TolFun or an
> output function. It strikes me that there might not be a unique minimum
> to your problem, but I could be wrong.
>
> Good luck,
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

Hi Alan

Thank you for your quick reply (and sorry If you received an incomplete response). I was saying that the constraint that I would like to impose is on the input "H" and not on the function value "cal6" (which is the function I am trying to minimize). In that case I have to set TolX to 1e-02 right? Can I just set the TolX to 1e-2 without setting up an output function as you suggested?
  Since "H" is a matrix, would the algorithm automatically calculates the differences btw the norms?


Thank you for your advice

Best
S

Subject: Fminsearch with matrix as an input

From: Alan Weiss

Date: 12 Aug, 2011 15:37:35

Message: 7 of 9

> Hi Alan
>
> Thank you for your quick reply (and sorry If you received an incomplete
> response). I was saying that the constraint that I would like to impose
> is on the input "H" and not on the function value "cal6" (which is the
> function I am trying to minimize). In that case I have to set TolX to
> 1e-02 right? Can I just set the TolX to 1e-2 without setting up an
> output function as you suggested?
> Since "H" is a matrix, would the algorithm automatically calculates the
> differences btw the norms?
>
>
> Thank you for your advice
>
> Best
> S

I do not understand what you mean when you say "the constraint that I
would like to impose is on the input "H" and not on the function value
"cal6" (which is the function I am trying to minimize)." What constraint
are you talking about? The exit condition (I mean the reason the
function stops iterating)?

To understand what TolX and TolFun do, look here:
http://www.mathworks.com/help/toolbox/optim/ug/f12471.html#brhv4_o-1

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: Fminsearch with matrix as an input

From: Saad

Date: 12 Aug, 2011 15:51:30

Message: 8 of 9

Alan Weiss <aweiss@mathworks.com> wrote in message <j23hbv$cvl$1@newscl01ah.mathworks.com>...
> > Hi Alan
> >
> > Thank you for your quick reply (and sorry If you received an incomplete
> > response). I was saying that the constraint that I would like to impose
> > is on the input "H" and not on the function value "cal6" (which is the
> > function I am trying to minimize). In that case I have to set TolX to
> > 1e-02 right? Can I just set the TolX to 1e-2 without setting up an
> > output function as you suggested?
> > Since "H" is a matrix, would the algorithm automatically calculates the
> > differences btw the norms?
> >
> >
> > Thank you for your advice
> >
> > Best
> > S
>
> I do not understand what you mean when you say "the constraint that I
> would like to impose is on the input "H" and not on the function value
> "cal6" (which is the function I am trying to minimize)." What constraint
> are you talking about? The exit condition (I mean the reason the
> function stops iterating)?
>
> To understand what TolX and TolFun do, look here:
> http://www.mathworks.com/help/toolbox/optim/ug/f12471.html#brhv4_o-1
>
> Alan Weiss
> MATLAB mathematical toolbox documentation


Hi Alan

Yes I mean the exit condition...I would like to pout the exit condition on "H" and not the function itself. Shall I set TolX to 1e-02 right? Then the norm would be calculated automatically I guess? Thank you

Best

S

Subject: Fminsearch with matrix as an input

From: Paul Kerr-Delworth

Date: 16 Aug, 2011 09:46:12

Message: 9 of 9

"Saad " <saad.badaoui07@imperial.ac.uk> wrote in message <j23i62$fop$1@newscl01ah.mathworks.com>...
> Alan Weiss <aweiss@mathworks.com> wrote in message <j23hbv$cvl$1@newscl01ah.mathworks.com>...
> > > Hi Alan
> > >
> > > Thank you for your quick reply (and sorry If you received an incomplete
> > > response). I was saying that the constraint that I would like to impose
> > > is on the input "H" and not on the function value "cal6" (which is the
> > > function I am trying to minimize). In that case I have to set TolX to
> > > 1e-02 right? Can I just set the TolX to 1e-2 without setting up an
> > > output function as you suggested?
> > > Since "H" is a matrix, would the algorithm automatically calculates the
> > > differences btw the norms?
> > >
> > >
> > > Thank you for your advice
> > >
> > > Best
> > > S
> >
> > I do not understand what you mean when you say "the constraint that I
> > would like to impose is on the input "H" and not on the function value
> > "cal6" (which is the function I am trying to minimize)." What constraint
> > are you talking about? The exit condition (I mean the reason the
> > function stops iterating)?
> >
> > To understand what TolX and TolFun do, look here:
> > http://www.mathworks.com/help/toolbox/optim/ug/f12471.html#brhv4_o-1
> >
> > Alan Weiss
> > MATLAB mathematical toolbox documentation
>
>
> Hi Alan
>
> Yes I mean the exit condition...I would like to pout the exit condition on "H" and not the function itself. Shall I set TolX to 1e-02 right? Then the norm would be calculated automatically I guess? Thank you
>
> Best
>
> S

Hi Saad,

TolX sets the tolerance on the exit condition of your variables, X. From a quick look at your code, these variables make up your matrix H. As such, you can think of TolX as an exit condition on the matrix H in this case.

The norm used in the stopping test in fminsearch is calculated automatically and you do not have to implement it.

Hope this helps!

Best regards,

Paul

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us