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

 Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 14 Dez. 2021
Bearbeitet: Cris LaPierre am 15 Dez. 2021

1 Stimme

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 Kommentar

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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by