I am trying to find the the value x that make y approximately zero. Here is what I did:
e= 0.001 %error bar
for x = linspace(100, 170, 1000);
y = 18.9*log(x/170) +0.0042*(x-170) + 8.314*log(0.000267/0.0001413);
end
Thanks in advance.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 12일

0 개 추천

e= 0.01 %error bar
x = linspace(100, 170, 1000);
y = 18.9*log(x/170) +0.0042*(x-170) + 8.314*log(0.000267/0.0001413);
idx=find(abs(y)<e)

댓글 수: 4

Abdullah Al-Alawi
Abdullah Al-Alawi 2015년 7월 12일
Thank you for your quick response. That really helped me, but I want to know the value of X. like what value of x between this range( 100 to 170) that make Y approximately equal to zero. Thank you though for your time.
If you are looking for the nearest value to 0.
e= 0.01 %error bar
x = linspace(100, 170, 1000);
y = 18.9*log(x/170) +0.0042*(x-170) + 8.314*log(0.000267/0.0001413);
[max_val,index_val]=min(abs(y))
Abdullah Al-Alawi
Abdullah Al-Alawi 2015년 7월 12일
Thank you! Much Appreciated!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2015년 7월 12일

1 개 추천

Consider
x0 = fzero( @(x) 18.9*log(x/170) +0.0042*(x-170) + 8.314*log(0.000267/0.0001413), [100, 170]);

댓글 수: 1

Abdullah Al-Alawi
Abdullah Al-Alawi 2015년 7월 12일
Thank you Walter! That's indeed a faster way! Much Appreciated! You Rock!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by