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!