필터 지우기
필터 지우기

How to show the negative value on the graph?

조회 수: 24 (최근 30일)
KIEN WEI LAI
KIEN WEI LAI 2020년 3월 15일
편집: Sindar 2020년 3월 15일
Hi everyone, I want to show all the values into the graph including positive value and negative value. This is the expected outcome:
However, I could not display the negative value below 0 at the y-axis, I only can display the positive value only which above 0.
This is the value that I wanted to insert into the graph from the txt file:
Anyone can help me to solve the problem? Thanks in advance.
This is the code that I am using:
semilogy(lai2(:,1),lai2(:,2),'-b')
  댓글 수: 2
Stephen23
Stephen23 2020년 3월 15일
"Anyone can help me to solve the problem?"
Errr... don't use semilogy.
What do you expect negative logarithms to represent?
KIEN WEI LAI
KIEN WEI LAI 2020년 3월 15일
I want to show the result as the expected result from the diagram. However, I could not display the negative algorithm.

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

답변 (1개)

Sindar
Sindar 2020년 3월 15일
편집: Sindar 2020년 3월 15일
If you want to plot both positive and negative data on a log scale, your best bet is to check out symlog: https://www.mathworks.com/matlabcentral/fileexchange/57902-symlog
(It answers a question you seem to be ignoring: what to do with something like -1.00E-01)
However, that doesn't actually seem to be your goal, since your Line #10 (value -3.48E-00) is plotted at -3.48, not -log(3.48) or something like that. And your tick marks are evenly spaced. Your "expected outcome" plot is not on a log scale. Just use plot:
plot(lai2(:,1),lai2(:,2),'-b')

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by