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')

When ever I publish this I wind up in a loop of figures popping up that doesnt stop unless I click ctrl+c.....Any suggestions on how to resolve this? I am trying to create a pdf that has all the graphs and comments I put into this code. First time using publish and when I look at the help function in matlab for the publish command it seems as though am doing it correctly.

Rob. B
  • 19
  • 5
  • Two asides: first, you should terminate those commands with semicolons; otherwise there is an awful lot of useless output in the command window. Second, when asking a question on SO, you should [create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) instead of just pasting the whole script as is. Many people will read a code sample with several lines; few will want to scroll and scroll in search of an issue. –  Mar 10 '16 at 22:26

1 Answers1

1

The command publish executes the script whose name is given, and records the output. Your mistake is inserting this command into the script itself. This results in an infinite loop: the script runs, then at the end encounters publish command, which means it has to run again, so it does, and then encounters publish, etc.

You should invoke

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

from the command window, not from the script itself.