%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中查看帮助函数的发布命令时,似乎正在正确地执行它。
答案 0 :(得分:1)
命令publish
执行给出其名称的脚本,并记录输出。您的错误是将此命令插入脚本本身。这导致无限循环:脚本运行,然后在最后遇到publish
命令,这意味着它必须再次运行,所以它会运行,然后遇到publish
等。
你应该调用
publish('lab2question1.m','pdf')
来自命令窗口的,而不是来自脚本本身。