negative data ignored when set axis to log
25 ビュー (過去 30 日間)
古いコメントを表示
kx = 5000;
Kx = 0.5;
ky = 5000;
Ky = 0.5;
K1 = 0.3;
K2 = 0.3;
kd = 0.7;
Hi, Here is my code below
I am meant to get 3 intersections but it won't plot my negative data when I log the graph
f1 = figure(1)
g = [-10000:0.1:100000];
f = (ky/kd)*(1./(1+K2*Kx*g.^2))
plot(g,f);
hold all
a = [-10000:0.1:100000];
b = (kx/kd)*(1./(1+K1*Ky*a.^2))
plot(b,a);
set(gca, 'XScale', 'log');
set(gca, 'YScale', 'log');
0 件のコメント
回答 (1 件)
Walter Roberson
2022 年 11 月 14 日
in order to figure out where on the screen to draw the lines when you are using log scale, matlab needs to take log() of the coordinates. If x is negative then log(x) is log(-x) + π*sqrt(-1) which is a complex value. Where should matlab plot items whose log coordinates are complex valued? Should plot() switch to a 3d view, with the third dimension being 0i (real values) and π*1i (complex values)?
Or since for any two positive values, the one with the smaller coordinate is drawn to the left of the one with greater coordinates, then should the negative coordinates be drawn to the left of the nonnegative ones? But -1 is less than 0 so log(-1)would have to be left of log(0)... which is a problem because log(0) is -infinity. So if you have a mix of negative and positive coordinates and log scale then every negative coordinate must be further left than infinitely left of any positive coordinates.
Conclusion: do not use log scale when you have negative coordinates.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!