Got Questions? Get Answers.
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:
Pass additional parameters to the obj fun of optimization routine?

Subject: Pass additional parameters to the obj fun of optimization routine?

From: pietro

Date: 21 Jun, 2011 19:09:20

Message: 1 of 4

Hi all,

I need to pass additional parameters to the objective function of an optimization routine. In particular I want to do this in the gui.

Is there a way?

Thanks

Bye

Pietro

Subject: Pass additional parameters to the obj fun of optimization routine?

From: Sadik

Date: 21 Jun, 2011 20:33:02

Message: 2 of 4

Hi Pietro,

You way take a look at this:

http://www.mathworks.com/support/solutions/en/data/1-19HM6/index.html?solution=1-19HM6

Best.

Subject: Pass additional parameters to the obj fun of optimization routine?

From: pietro

Date: 21 Jun, 2011 21:26:04

Message: 3 of 4

"Sadik " <sadik.hava@gmail.com> wrote in message <itqv5u$deo$1@newscl01ah.mathworks.com>...
> Hi Pietro,
>
> You way take a look at this:
>
> http://www.mathworks.com/support/solutions/en/data/1-19HM6/index.html?solution=1-19HM6
>
> Best.

thanks Sadik,

I read it, but unfortunately I haven't understood how to pass them from the gui...Do you have any idea?

thanks

Pietro

Subject: Pass additional parameters to the obj fun of optimization routine?

From: Sadik

Date: 21 Jun, 2011 21:35:21

Message: 4 of 4

In the gui, you are going to have edit boxes. I will modify the example in the above link.

I am assuming you put two edit boxes: one for p1 and the other for p2. Then, into the callback of you "Compute" button:

x0 = [10; 10; 10];
p1 = str2double(get(handles.edit1,'String'));
p2 = str2double(get(handles.edit2,'String'));
lb = [0 0 0];
ub = [ 50 50 50];

options = optimset('Largescale','off','Display','iter');
[x, fval] = fmincon(@(x)fun(x,p1), x0, [], [], [], [], lb, ub, @(x)nonlcon(x,p1,p2), options)

You can easily extend this to x0, lb and ub, if you'd like.

Tags for this Thread

No tags are associated with 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