Borrar filtros
Borrar filtros

change value of inline function during loop for a string function

1 visualización (últimos 30 días)
Orestes
Orestes el 30 de Jul. de 2014
Respondida: Jian Wei el 31 de Jul. de 2014
Hi guys,
I have the follwoing inline function I'd like to perform newton's method (solving for 'x'):
fp = inline('-(q/(q+x))+((1-q)/(1-q-x))'); f = inline('q*log(q/(q+x))+(1-q)*log((1-q)/(1-q-x))-eps');
I would like to change the value of q in every loop iteration, but simply setting q=0.01 before calling the inline functions won't change the value of q.
any suggestions?

Respuestas (1)

Jian Wei
Jian Wei el 31 de Jul. de 2014
According to your definitions of fp and f, q and x are the input arguments to these two inline functions. To compute the function values for different q and x, you need to pass the values of q and x to these inline functions. For example, you can try the following commands to compute the function values for q = 0.01 and x = 1:
q = 0.01;
x = 1;
val_fp = fp(q,x);
val_f = f(q,x);

Categorías

Más información sobre Function Creation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by