MATLAB代码:写一个基于GUI的电话按键拨号系统,产生并检测DTMF信号,并能检验拨号是否正确

时间: 2024-03-17 07:44:33 浏览: 23
好的,以下是一个简单的基于GUI的电话按键拨号系统的MATLAB代码,可以产生和检测DTMF信号,并验证拨号是否正确: ```matlab function phone_dialer_gui % create the GUI window fig = figure('units','normalized','position',[0.4,0.4,0.2,0.3],'name','Phone Dialer',... 'menubar','none','numbertitle','off'); % create the number buttons num_button = cell(4,3); num = 1; for i = 4:-1:1 for j = 1:3 num_button{i,j} = uicontrol('style','pushbutton','string',num2str(num),... 'units','normalized','position',[(j-1)*0.33,0.2+(i-1)*0.2,0.33,0.2],... 'callback',@dial_number); num = num+1; end end % create the dial button dial_button = uicontrol('style','pushbutton','string','Dial','units','normalized',... 'position',[0.66,0.6,0.33,0.2],'callback',@dial_number); % create the hangup button hangup_button = uicontrol('style','pushbutton','string','Hang Up','units','normalized',... 'position',[0.66,0.2,0.33,0.2],'callback',@hang_up); % initialize the phone number phone_number = ''; % callback function for dialing a number function dial_number(source,event) button = source.String; % get the number from the button phone_number = [phone_number,button]; % add the number to the phone number sound(dtmfgen(get_dtmf_freq(button))); % generate the DTMF sound end % callback function for hanging up function hang_up(source,event) if strcmp(phone_number,'') % check if there is a phone number to hang up msgbox('No phone number to hang up.','Hang Up','warn'); else detected_number = detect_dtmf(phone_number); % detect the DTMF signal if strcmp(detected_number,phone_number) % check if the detected number is the same as the dialed number msgbox(['Dialing ',phone_number,'... Phone is ringing.'],'Dialing','help'); else msgbox(['Incorrect dial. Detected number is ',detected_number,'. Please try again.'],... 'Incorrect Dial','error'); end phone_number = ''; % reset the phone number end end % function to get the DTMF frequency for a button function freq = get_dtmf_freq(button) switch button case '1' freq = [697,1209]; case '2' freq = [697,1336]; case '3' freq = [697,1477]; case '4' freq = [770,1209]; case '5' freq = [770,1336]; case '6' freq = [770,1477]; case '7' freq = [852,1209]; case '8' freq = [852,1336]; case '9' freq = [852,1477]; case '*' freq = [941,1209]; case '0' freq = [941,1336]; case '#' freq = [941,1477]; otherwise freq = [0,0]; end end % function to detect the DTMF signal for a phone number function number = detect_dtmf(phone_number) freq1 = [697,770,852,941]; freq2 = [1209,1336,1477]; detected_number = ''; for i = 1:length(phone_number) freq = get_dtmf_freq(phone_number(i)); signal = dtmfgen(freq); detect_freq = dtmfdet(signal); if ismember(detect_freq(1),freq1) && ismember(detect_freq(2),freq2) detected_number = [detected_number,num2str(find(freq1==detect_freq(1))),... num2str(find(freq2==detect_freq(2)))]; end end number = detected_number; end end ``` 这段代码创建了一个GUI窗口,包括数字键盘和拨号按钮。当用户按下数字键时,程序会产生相应的DTMF信号。当用户点击拨号按钮时,程序会检测产生的DTMF信号是否正确,并在GUI界面上显示拨号成功或失败的消息。

相关推荐

最新推荐

recommend-type

基于MATLAB的DTMF信号系统仿真

高的拨号速度, 另一方面它便于自动检测 识别及电话业务的扩展, 所以很快代替了 原有的脉冲计数方式的拨号形式。 在这里不得不提一下电话交换机的发 展历史。自1876 年美国贝尔发明电话以 来, 电话交换技术发展主要...
recommend-type

基于Yolov5的旋转检测

旋转检测 要求 torch==1.6 shapely==1.7.1 opencv==4.2.0.34
recommend-type

MATLAB 代码解决 Timothy Sauer 的教科书“数值分析”第三版中的两组计算机问题.zip

1.版本:matlab2014/2019a/2021a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

SQL怎么实现 数据透视表

SQL可以通过使用聚合函数和GROUP BY子句来实现数据透视表。 例如,假设有一个销售记录表,其中包含产品名称、销售日期、销售数量和销售额等信息。要创建一个按照产品名称、销售日期和销售额进行汇总的数据透视表,可以使用以下SQL语句: ``` SELECT ProductName, SaleDate, SUM(SaleQuantity) AS TotalQuantity, SUM(SaleAmount) AS TotalAmount FROM Sales GROUP BY ProductName, SaleDate; ``` 该语句将Sales表按照ProductName和SaleDat
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

实现实时监控告警系统:Kafka与Grafana整合

![实现实时监控告警系统:Kafka与Grafana整合](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2pwZy9BVldpY3ladXVDbEZpY1pLWmw2bUVaWXFUcEdLT1VDdkxRSmQxZXB5R1lxaWNlUjA2c0hFek5Qc3FyRktudFF1VDMxQVl3QTRXV2lhSWFRMEFRc0I1cW1ZOGcvNjQw?x-oss-process=image/format,png) # 1.1 Kafka集群架构 Kafka集群由多个称为代理的服务器组成,这