필터 지우기
필터 지우기

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 CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by