Simulink "MATLAB Function" block and extremum value

1 view (last 30 days)
Anne on 29 Jan 2023
Commented: Anne on 29 Jan 2023
Hello. I am trying to use single input and single output Simulink matlab code function block: MATLAB function. I use the input value "u" to calculate the output value "y", which should be the maximum value of the function "factor (v, u)". The function "factor" depends on the Simulink block input "u" as well as the value which is needed to be found as output ("y" or "result" or "fcn(u)").
How could I find the maximum extremum value for the function factor(v,u) and which value for parameter "v" is needed to have the maximum value for factor (v, u) function? The result or output of the Simulink function block is the parameter value "v" which gives the maximum value for factor (v,u). How could I do it in correct way?
function y = fcn(u)
%function factor(v,u)
y = result;

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 29 Jan 2023
Note that there are a couple of important points here. (1) v input argument values have to be given/known to perform the calculations of your stated formulation. (2) therefore, there must be two input arguments to MATLAB fcn block. Considerign these two points ehre is the completed code of fcn:
function y = fcn(u, v)
[~, IDX] = max(H);
y = v(IDX);
One simple simulink model (Sim_Demo.slx) is attached to this post with this code.
Anne on 29 Jan 2023
I am trying to solve an equation for "v" which could give the maximum value for the function H(u, v) with given "u". So, basically in this matlabcode once the input value (u) is know because it is given to function block), I am trying to solve function H(u,v) to find max. H(u,v) and the value for parameter "v" (unknown in this case) that can give the maximum value for H(u,v). It is like an extremum problem for unknow "v" because "u" will be known once SImulink provides that value to the function block.

Sign in to comment.


Find more on General Applications in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by