change value of inline function during loop for a string function

2 views (last 30 days)
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?

Answers (1)

Jian Wei
Jian Wei on 31 Jul 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);

Categories

Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!