フィルターのクリア

change value of inline function during loop for a string function

1 回表示 (過去 30 日間)
Orestes
Orestes 2014 年 7 月 30 日
回答済み: Jian Wei 2014 年 7 月 31 日
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?

回答 (1 件)

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

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by