SIMULINK: Using FMINSEARCH online for xpctarget
2 次查看(过去 30 天)
显示 更早的评论
Hey everyone I am having some issues. So I have this problem where I am using simulink to design an adaptive controller. I essentially take a set of data over a set of say 1 second and identify the main frequencies. With those identified frequencies I calculate my controller. I am trying to essentially minimize the coefficients of my controller to get enough gain to do the job but not to much that it will increase noise.
I insert a user-defined function and basically pass it the frequencies and try to fun "fminsearch" inside the block. The actual cost funciton is also a user defined function. Now I know the the command I am using will work when I do it in matlab and pass it the frequencies it will give me the correct coefficients out.
Is fminsearch and fmincon not useable in simulink? I just need a way to minimize a cost function "online" in simulink.
0 个评论
回答(3 个)
Guy Rouleau
2011-10-17
In simulation, you can call fminsearch or fmincon from MATLAB S-function of from the MATLAB function as extrinsic.
You cannot generate code from fminsearch or fmincon. Only the functions listed here can generate and be used on xPC Target:
1 个评论
Yanbo
2013-8-15
Hey, Guy,
The link is not valid now.
If I want to use xPC target to perform somet optimization calculations in real time, given that fmincon and fminsearch are not applicable in xPC, what else can I resort to?
Cheers,
Yanbo
Guy Rouleau
2011-10-17
In simulation, you can call fminsearch or fmincon from MATLAB S-function of from the MATLAB function as extrinsic.
You cannot generate code from fminsearch or fmincon. Only the functions listed here can generate and be used on xPC Target:
1 个评论
Gulzar Baig
2017-6-10
编辑:Gulzar Baig
2017-6-10
Dear Guy, My Simulink model is an 'objective function' itself. There are two parameters that I wish to optimize to curve fit the data using fminsearch (block).
So what I mean is that I put fminsearch block and connect the LSE to its input while the two parameters from its output are connected to the Simulink model. The simulation runs until parameters are found (Hint: Root finding in Algebriac Constaint). OR how to call fminsearch from S-function??? Any help....
Jakub
2014-6-30
Hi Guy,
In recent Matlab editions the nubmer of functions supported by code generation changed. According to
the list includes fminsearch. However the usage scenario of fminsearch and other optimization functions is that we are usually using anonymous/nested functions in order to pass parameters to the function being optimized. Both approaches are unsupported by code generation. Therefore what is a preferred way of passing additional, user-defined parameters to functions like fminsearch?
Cheers, Jakub
3 个评论
Jakub
2014-6-30
Thank you Ryan for the answer and the link. I must say that I am not a fan of persistent variables and globals, but it is the most reasonable solution for now.
Cheers, Jakub
Ryan Livingston
2014-6-30
I definitely share your sentiments about the need to use persistents here. But as you say, I believe this to be the most reasonable solution at present.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!