fix parameters in function
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
John Miller
el 22 de Sept. de 2020
Comentada: Warren Boschen
el 27 de En. de 2023
I want to optimize one parameter of a function with three parameters. Lets say the function looks like this
function f = function(t,x)
f = x(1) + x(2) *x(3)
end
How can I transmit the values for x(1) and x(2) but leave x(3) open to a later optimization?
0 comentarios
Respuesta aceptada
Ameer Hamza
el 22 de Sept. de 2020
Yes, you can only optimize using selected variables. For example, following use x(3) for optimization, while x(1) and x(2) are fixed.
x1 = 2; % write value of x(1)
x2 = 3; % write value of x(2)
t = 0; % write value of t
x30 = rand(); % initial guess for x3
sol = fmincon(@(x3) myFunction(t, [x1; x2; x3]), x30)
function f = myFunction(t,x)
f = x(1) + x(2) *x(3)
end
3 comentarios
Torsten
el 27 de En. de 2023
sol = fmincon(@(x) myFunction(data1, data2, x(1), x(2)), [x0, y0]);
Más respuestas (0)
Ver también
Categorías
Más información sobre Problem-Based Optimization Setup en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!