how can i change Y-axis into log and dont get Warning: Negative data ignored

9 ビュー (過去 30 日間)
zhu ting
zhu ting 2015 年 10 月 1 日
編集済み: Walter Roberson 2015 年 10 月 14 日
I am writing a Programm that turned both Axis into log10, here is my Programm:
x=real(lambda)/W0;
y=imag(lambda)/W0;
figure
plot(x,y,'*')
set(gca,'xscale','log')
set(gca,'yscale','log')
grid on
Lambda and W0 are two Input Data.
This Programm run very well when i just delete 'set(gca,'yscale','log')', but with this sentence then a Warning Negative data ignored will be pupped out. Is there any way that will let my y-axis being turned into 'log' and at the same time with negative data?
PS: i also tried LOGLOGPN but my plot is a lots of dots not a line so its also not working.
Mit freundlichen Grüßen
Ting Zhu
  1 件のコメント
zhu ting
zhu ting 2015 年 10 月 1 日
編集済み: Walter Roberson 2015 年 10 月 14 日
and here is what my data for example:
lambda=[-1;-2;-3+2j;-3-2j;-4+3j;-4-3j];
W0=1;

サインインしてコメントする。

回答 (1 件)

Kirby Fears
Kirby Fears 2015 年 10 月 1 日
Hi Zhu,
The log function is undefined for negative values. Have a look at the wiki page .
Matlab can't apply log to the negative values, so it just ignores them.
Hope this helps.
  2 件のコメント
zhu ting
zhu ting 2015 年 10 月 9 日
but all my X-data are negative values and ist working without any Warning. Do u know why?
Here is my Input for example:
lambda=[-1;-2;-3+2j;-3-2j;-4+3j;-4-3j];
W0=1
Thanks
Kirby Fears
Kirby Fears 2015 年 10 月 13 日
Log is not applied to the X values. Look at the X axis before and after the statement
set(gca,'xscale','log')
You will see that the X axis still has the exact same values as before. The values are only repositioned along the axis.
This allows you to plot log(y) against the original x values that generated y, but spaced in such a way that the plot is more readable.
Hope this helps.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by