Hello!. I am very new to matlab and wanna know how can I plot
y=(1-2*x)*log((1-x)/x) function?
I tried to write it like that but it did not work as i expected.. It plots something else..
thanks..
and also why i cannot plot (1/x)? thanks.

댓글 수: 2

Geoff Hayes
Geoff Hayes 2015년 3월 8일
Kemal - what is the code that you are using to plot your above y? What have you initialized x as?
kemal sen
kemal sen 2015년 3월 8일
편집: Walter Roberson 2020년 11월 16일
I used this
x=0:0.2:1;
y=(1-2*x)*log((1-x)/x) ;
plot(x,y)

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

답변 (2개)

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015년 3월 8일
편집: Giorgos Papakonstantinou 2015년 3월 8일

1 개 추천

The problem occurs inside the log parenthesis. The syntax that you have used tells Matlab to solve the equation:
x = B/A
for x. Check the documentation for mrdivide to get more a thorough explanation.
If you want to do element-wise arithmetic operations (division, power, etc.) then you have to use . before each operation. Look for more information here.
In your case you have to modify your equation:
y=(1-2.*x).*log((1-x)./x)
Here the log function computes the natural logarithm.
or
y=(1-2.*x).*log10((1-x)./x)
Here the log10 function computes the logarithm when the base is 10
For example if:
x=0:0.02:1;
y=(1-2*x).*log((1-x)./x) ;
plot(x,y)
the result is:

댓글 수: 1

kemal sen
kemal sen 2015년 3월 8일
편집: kemal sen 2015년 3월 8일
Thank you very much..

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

D tk
D tk 2020년 11월 16일

0 개 추천

plot y=0.5*ln(pi*e),e is exp^1

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

질문:

2015년 3월 8일

댓글:

2020년 11월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by