2016-03-09 19 views
1
%Question 1 


y=dtmfsig(150006260); 

%a 
t= linspace(0,0.9,7200) 
plot(t,y) 
title('DTMF time signal') 
xlabel('t (sec)') 
ylabel(' y(t)') 




% Part B 

fLH= [697, 770, 852, 941, 1209, 1336, 1477] 


%Signal divided into 3 sections 
fs= 8000 
T=1/fs 


y1= y(1:2400);  
y2=y(2401:4800); 
y3=y(4801:7200); 


% Seven point DTFT 

Dy1= freqz(y1, 1, 2*pi*T*fLH); 
Dy1n= abs(Dy1) 

% 1 



Dy2= freqz(y2, 1, 2*pi*T*fLH); 
Dy2n= abs(Dy2) 

% 3 

Dy3= freqz(y3, 1, 2*pi*T*fLH); 
Dy3n= abs(Dy3) 


% 2 


% In each of these sections I used the given keypad to determine what my 
% output would be based on the maximums in the matrix. I wrote what those 
% numbers would be under each set of commands but to recap they are in 
% order 1,3,2 

%c 

t1= 600:1:1600 
%First DTFT (Need to put points in Dy1n in) 
Dc1= freqz(y1, 1, t1.*2.*pi.*T) 
Dc1n= abs(Dc1) 
plot(t1, Dc1n./abs(max(Dc1n))) 
title(' normalized spectrum of decode key 5') 
xlabel(' frequency (Hz) ') 
ylabel(' magnitude') 


Dc2= freqz(y2, 1, t1.*2.*pi.*T) 
Dc2n=abs(Dc2) 
plot(t1, Dc1n./abs(max(Dc2n))) 
title('normalized spectrum of decode key 3') 
xlabel('frequency (Hz)') 
ylabel('magnitude') 



Dc3= freqz(y3, 1,t1.*2.*pi.*T) 
Dc3n=abs(Dc3) 
plot(t1, Dc1n./abs(max(Dc3n))) 
title('normalized spectrum of decode key 8') 
xlabel('frequency (Hz)') 
ylabel('magnitude') 


% In this secion I computed the DTFT of the three segements that I divided 
% the signal into and then graphed them. 


%d 

% For the last part of this question I created a table that shows the 
% normalized values for the 3 different key values that are displayed in 
% the graphs above 
d= [fLH; Dy1; Dy2; Dy3]; 

fprintf('%6s | %10s %10s %10s\n', 'f', 'key 5', 'key 3', 'key 8') ; 
fprintf('-----|------------------------------------------\n'); 
fprintf('%6.d| %10.3f %10.3f %10.3f\n',d); 

publish('lab2question1.m','pdf') 

發佈當過我發佈這個我在數字雨後春筍般冒出來,這並不停止循環風,除非我點擊CTRL + C時,在一個無限循環滯留.....任何建議上如何解決這個問題?我正在嘗試創建一個包含所有圖形和註釋的pdf,並將其放入此代碼中。第一次使用發佈,當我在matlab中查看發佈命令的幫助函數時,似乎是在正確地執行它。試圖用Matlab中

+0

兩個旁白:首先,你應該用分號終止這些命令;否則在命令窗口會出現很多無用的輸出。其次,在提出關於SO的問題時,應該[創建一個最小化,完整和可驗證的示例](http://stackoverflow.com/help/mcve),而不是僅僅粘貼整個腳本。很多人會用幾行代碼讀取代碼示例;很少有人會想要滾動和滾動尋找問題。 –

回答

1

該命令publish執行腳本的名字給出,並記錄輸出。您的錯誤是將此命令插入腳本本身。這導致了一個無限循環:腳本運行,然後在最後遇到publish命令,這意味着它必須再次運行,它確實是這樣,然後遇到publish

你應該調用

publish('lab2question1.m','pdf') 

命令窗口,而不是腳本本身。