need help: optimization using fmincon in a simulink level-2 matlab s-function block

Hi,
I would like to express the following objective function in a simulink level-2 matlab s-function block using fmincon as solver:
f(x,y) = x*tan(y(k+1)) + c*(y(k+1)-y(k))
where k is the step time.
My problem is in the variable y, I can't express it to be able to use it in fmincon and, all my attempts so far have been unsuccessful.
Your help will be very important to me!
Thank you...

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 3월 11일
편집: Ameer Hamza 2020년 3월 11일
To use fmincon, the objective function must accept a single input variable, which can be a vector. So for your function, you can pass it to fmincon as
sol = fmincon(@(x) f(x(1), x(2)), ..... )
Note that the initial point x0 also need to be 1x2. The returned value will also be 1x2.

댓글 수: 5

what you say is true, but if you look closely at this expression, you will notice that the function f(x,y) depends on the previous and next value of the input variable y, or in your case X(2).
My problem is indeed at this level. ie express y(k+1)-y(k) with y=1x1.
thanks
I missed that point. How is your objective function defined mathematically? Are x and y vectors or scalar? Does y(k+1)-y(k) denotes difference of two consecutive elements of vector y, or is it a difference in time?
y(k+1) -y(k) is it a difference in time
I am not sure whether fmincon can help in such a case. You may need to reformulate the optimization problem such that the value of the objective function can be evaluated just by using input variables.
All right, thanks for your help.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Simulink Design Optimization에 대해 자세히 알아보기

제품

릴리스

R2015a

질문:

2020년 3월 11일

댓글:

2020년 3월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by