2015-04-04 91 views
1

我试图在matlab上绘制一个简单的函数,但它显示一个空的图。plot(x,y)显示一个空的图

x=0.001:1; 
y=15/x; 

figure 
plot(x,y) 
xlabel('Pr/Pn (dB)') 
ylabel('Processing gains (dB)') 


这里是我的了:

enter image description here

回答

6

你只积一分,点(0.001,15/0.001)=(X,Y)。 你可能想是这样的:

x = 0:0.001:1 
y = 15./x 
figure 
plot(x,y) 
... 
1

那么首先x=0.001:1的产生你一个值,但不是一个array.Change到x=0:0.001:1

其次y=15./x会给你一个无限大的x(1)= 0,你得到一个零除。

最后:

x_n=x(2:end); % taking out first 0 term 
y=15./x_n(2:end); 
plot(x,y) 

enter image description here