尝试在Matlab中使用发布时陷入无限循环 [英] Stuck in an infinite loop when trying to use publish in Matlab

查看:311
本文介绍了尝试在Matlab中使用发布时陷入无限循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

%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文件,其中包含我在此代码中放入的所有图形和注释.第一次使用publish,当我在matlab中查看publish命令的帮助功能时,似乎好像正确地进行了操作.

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.

推荐答案

命令publish 执行指定名称的脚本,并记录输出.您的错误是将此命令插入脚本本身.这将导致无限循环:脚本运行,然后最后遇到publish命令,这意味着它必须再次运行,然后才运行,然后遇到publish,等等.

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.

您应该调用

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

命令窗口,而不是脚本本身.

from the command window, not from the script itself.

这篇关于尝试在Matlab中使用发布时陷入无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆