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');

 採用された回答

Cris LaPierre
Cris LaPierre 2021 年 12 月 14 日
編集済み: Cris LaPierre 2021 年 12 月 15 日

1 投票

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 件のコメント

Walter Roberson
Walter Roberson 2021 年 12 月 14 日
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 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by