How to use Embedded MATLAB Function to calculate the maximum of a single-variable function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Good afternoon.
I'd like to know how to use Embedded MATLAB Function to calculate the maximum of a single-variable function, that is, if the function is y=f(x), I want to calculate [xmax, ymax]. I have made a m-file and it works when I run it from MATLAB, but when I type all the code in the Embedded MATLAB Function block, it doesn't work.
-----------------------------------------------------------------------------------------------------------
function [Cpopt,TSRopt]=optimo(beta)
Cp=@(lambda) -0.5176*(116*(1/(lambda+0.08*beta)-0.035/(beta^3+1))-0.4*beta-5)*exp(-21*(1/(lambda+0.08*beta)-0.035/(beta^3+1)))-0.0068*lambda;
TSRopt=fminbnd(Cp,0,14);
Cpopt=0.5176*(116*(1/(TSRopt+0.08*beta)-0.035/(beta^3+1))-0.4*beta-5)*exp(-21*(1/(TSRopt+0.08*beta)-0.035/(beta^3+1)))+0.0068*TSRopt;
-----------------------------------------------------------------------------------------------------------
This code should calculate the maximum of Cp=Cp(lambda), [lambda_opt, Cp_opt]. It seems that this block doesn't recognize "fminbnd" or the structure "function=@(variable).....".
NOTE: To calculate the maximum of Cp using "fminbnd" I have to calculate the minimum of -Cp.
Regards!
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!