【数字信号】基于GUI虚拟信号发生器(各种波形)【Matlab 271期】
作者:互联网
一、案例简介
1 应用背景
传统的台式函数信号发生器具有体积庞大,接口不灵活,波形固定,价格昂贵等缺点,针对此现状,本次根据老师布置的作业完成一个简单的数字信号发生器,可以产生不同幅值,频率的白噪声、正弦波、锯齿波、方波。工具选择为matlab,它具有强大的数据分析功能和数据处理功能,其自带的库函数为信号波形的产生带来了很大的方便。正文详细介绍了通过计算机声卡如何完成虚拟数字信号发生器的基本原理以及出现波形所需要实现的具体函数。
2 课题介绍
本文主要介绍了利用计算机编程工具matlab,通过计算机声卡实现虚拟数字信号发生器的基本原理以及实现步骤;针对传统数字信号发生器的缺点,完成虚拟数字信号发生器的设计,实现简单数字信号如三角波、锯齿波、方波、白噪声等的发生。
3 技术路线
声卡是实现声波/数字信号相互转换的一种硬件,在一般通常使用的PC机配置声卡中,大豆提供了麦克风输入和扬声器输出2个接口,他们集成了信号IO需要的模/数转换器(ADC)和数/模转换器(DAC)。因此,我们只需要将产生的数字信号通过音频线引出即可获得声音输出。
所有波形由matlab中所带的函数绘制完成,通过固定的接口函数,完成波形与声卡的对接,从而实现波形与音频信号的转换。
二、部分源代码
function varargout = signal_prodoce_comlpete(varargin)
% SIGNAL_PRODOCE_COMLPETE M-file for signal_prodoce_comlpete.fig
% SIGNAL_PRODOCE_COMLPETE, by itself, creates a new SIGNAL_PRODOCE_COMLPETE or raises the existing
% singleton*.
%
% H = SIGNAL_PRODOCE_COMLPETE returns the handle to a new SIGNAL_PRODOCE_COMLPETE or the handle to
% the existing singleton*.
%
% SIGNAL_PRODOCE_COMLPETE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SIGNAL_PRODOCE_COMLPETE.M with the given input arguments.
%
% SIGNAL_PRODOCE_COMLPETE('Property','Value',...) creates a new SIGNAL_PRODOCE_COMLPETE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before signal_prodoce_comlpete_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to signal_prodoce_comlpete_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help signal_prodoce_comlpete
% Last Modified by GUIDE v2.5 22-Sep-2009 21:56:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @signal_prodoce_comlpete_OpeningFcn, ...
'gui_OutputFcn', @signal_prodoce_comlpete_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% --- Executes just before signal_prodoce_comlpete is made visible.
function signal_prodoce_comlpete_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to signal_prodoce_comlpete (see VARARGIN)
% Choose default command line output for signal_prodoce_comlpete
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes signal_prodoce_comlpete wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = signal_prodoce_comlpete_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.
标签:signal,GUI,PRODOCE,prodoce,271,handles,Matlab,comlpete,gui 来源: https://blog.csdn.net/m0_54742769/article/details/120375254