change value of inline function during loop for a string function
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Jian Wei
2014-7-31
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!