Borrar filtros
Borrar filtros

how to combine several functions

16 visualizaciones (últimos 30 días)
pemfir
pemfir el 28 de Sept. de 2012
i have the following functions:
f1 = @(k1)108.4*k1
f2 = @(k2)108.4*k2
f3 = @(k3)108.4*k3
f1,f2,f3 are automatically generated, and can be very different. i would like to have a unifying function
f = f1 + f2 + f3
and i want to call f in solvers such as fsolve or fmincon.
Thank you !

Respuesta aceptada

per isakson
per isakson el 28 de Sept. de 2012
Editada: per isakson el 28 de Sept. de 2012
Hint:
f1 = @(k1)108.4*k1;
f2 = @(k2)108.4*k2;
f3 = @(k3)108.4*k3;
sumf = @(k1,k2,k3) f1(k1)+f2(k2)+f3(k3);
sumf( 1, 2, 3 )
ans =
650.4000
or
sumf = @(k) f1(k)+f2(k)+f3(k);
sumf( 2 )
ans =
650.4000
>>
  2 comentarios
pemfir
pemfir el 28 de Sept. de 2012
I truly appreciateeeeeeeeeee it !
pemfir
pemfir el 28 de Sept. de 2012
but this does not work with fsolve !!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surrogate Optimization en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by