How can I plot loglog(x,y) with experimental data including negative and less than one
조회 수: 9 (최근 30일)
이전 댓글 표시
I tried to plot a big set of experimental data which in 'x' axis ranges from negative data to positive, and also includes data less and more than 1.0. if I use loglog(abs(x),y) , obviously it draws both negative and positive 'x' values in one side, but I want to keep sign of 'x' values while converting to log scale. Also tried to define xlog = sign(x).*log10(abs(x)); but problem didn't solve, it is not like loglog. Any comments please how to do that?? Thanks
댓글 수: 1
Thomas Koelen
2015년 4월 24일
Whay do you mean by keeping the sign of the x values? you can't plot negative values on a loglog scale.
채택된 답변
Michael Haderlein
2015년 4월 24일
Why do you want a logarithmic plot of this data? Usually, when using loglog (or semilog) the point is that a change from, let's say, 1e-5 to 1e-4 is about as important for understanding as a change from 10 to 100. So, relative changes matter rather than absolute changes. However, relative changes don't change the sign.
I remember once there was a similar issue, we did want to pronounce relative changes, but some data sets were positive and others were negative (no change in sign within one set). We then used abs(data) to allow for the logscale, but applied different line styles/colors to emphasize the different signs. Honestly, it's ok but not too intuitive.
추가 답변 (2개)
MD
2015년 4월 24일
There is no side (as a reference to zero) on a log scale. You can try separating your x into negatives and positives. And then plot log of absolute values on two separate graphs.
xPositive = x(x>0);
yPositive = y(x>0);
xNegative = abs( x(x<0) );
yNegative = y(x<0);
figure(1)
semilogx(xPositive, yPositive);
figure(2)
semilogx(xNegative, yNegative);
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!