i=1; for x=0:0.01:1 t(i)=4905.5/(log10(x/(1-x)*sqrt((1-0.5*0.08*x)/(100000*(0.09-0.5*0.08*x))))+4.6455); i=i+1; end x=0:0.01:1; plot(x,t) xlabel('X') ylabel('T') title('X-T') axis([0 1 0 6000]) 为什么告诉我plot(x,y)是错的!?
plot没有错,是log(0)错误。Warning: Log of zero.> In log10 at 20Warning: Divide by zero.避免的办法是加一个eps。 i=1; for x=0:0.01:1 t(i)=4905.5/(log10(eps+x/(1-x+eps)*sqrt((1-0.5*0.08*x)/(100000*(0.09-0.5*0.08*x))))+4.6455); i=i+1; end x=0:0.01:1; plot(x,t) xlabel('X') ylabel('T') title('X-T') axis([0 1 0 6000]) |
|