why this code doesn't run?

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

 Risposta accettata

Cris LaPierre
Cris LaPierre il 14 Dic 2021
Modificato: Cris LaPierre il 15 Dic 2021
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 Commento

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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by