why this code doesn't run?
G = 10^-8 : 10^0;
G_0 = 10^-7 : 10^0;
y = log (G./G_0);
D = (4/pi)*(1/1-G./G_0)*(1-((G./G_0)/(1-G./G_0))*y)-(2/pi);
plot (G./G_0,D);
whitebg ('w');

 采纳的回答

It runs and does not contain an error (I edited your post to run you code).
The issue is that G is a single number, 1e-8, and G_0 is 1e-7.
The plot command does not include a marker style by default; just a line style. When you plot a single point, their is no line, so nothing appears. Add a marker style to your plot command to see you point.
G = 10^-8 : 10^0;
G_0 = 10^-7 : 10^0;
y = log (G./G_0);
D = (4/pi)*(1/1-G./G_0)*(1-((G./G_0)/(1-G./G_0))*y)-(2/pi);
% vvv specified a marker style
plot (G./G_0,D,'o');

1 个评论

Remember that for
G = 10^-8 : 10^0;
that the default increment for the : operator is 1. So 10^-8:10^0 starts with 10^-8 in the results; then it tests (10^-8+1) and finds that value is greater than the endpoint 10^0 so there are no further values to be produced by the : operation.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Log Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by