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

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에 대해 자세히 알아보기

질문:

2021년 12월 14일

편집:

2021년 12월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by