In my optimization lower bound of the optimization is a function of optimaztion variables. How can I solve it? fmincon can be able to do it or another optimization tools can be chosen?
I corrected the mistake there. How can I formulate nonlcon? lb = 0.1687 * z(i) where z(i) is a function of x(i) and explicit form. If that is nonlinear inequality constraint then what will be written in lb? Is lb = [] ?
Another thing is how did you wrote objective function in a beautiful way? Any matlab command to write or simplify my objective function? For small 2-3 variables it is easy to write manually but for large variable it is difficult. @Torsten
How can I formulate nonlcon? lb = 0.1687 * z(i) where z(i) is a function of x(i) and explicit form. If that is nonlinear inequality constraint then what will be written in lb? Is lb = [] ?
Set c(i) in nonlcon as the expression that you want to have <= 0. E.g. if you wanted to have x(i) >= 0.1687*v(i) for i = 1,2,3, compute v(i) and set c(1:3) = 0.1687*v(1:3) - x(1:3).
Another thing is how did you wrote objective function in a beautiful way? Any matlab command to write or simplify my objective function? For small 2-3 variables it is easy to write manually but for large variable it is difficult.
I did nothing - it's the usual display style for MATLAB Online.
You really need to look further into your lb being empty. lb being empty means the same as -infinity as the lower bound. However, you have division by several of your variables, so you would pass through infinity at 0.
I'm not sure if the input x-vector to "nonlcon" is a column vector. If it's a row vector, you will have to transpose either x or z in the above code fragment.
The first of those accepts a parameter that for the purposes of the function will be referred to ax x1 . It proceeds to ignore that parameter and to try to calculate 0.1687*z(1)-x(1) . It happens that x(1) is defined because of the
x = sym('x', [1, n]);
so you are defining an anonymous function that refers to unresolved symbolic variables. That will fail at evaluation time, as the result of the nonlinear constraints must be numeric and not contain any unresolved symbolic functions.
I suspect that what you are trying to say is that you expect
When a @() expression is constructed, the code after the @() expression is saved literally (except with extra spaces taken out and with commas inserted into lists), along with copies of the current values of all variables that have been mentioned by name; when the anonymous function is executed, the saved workspace is inserted and the code is executed.
To be explicit, when a @() expression is constructed, MATLAB does not evaluate any of the terms -- MATLAB would not construct
the function handle that is stored will record z and i and will use the recorded z and i at the time of execution, so that at execution time it will get the correct values. It will execute without problem; you do not need to change it.
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.