2015-04-04 41 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