【信号处理】基于matlab模拟数字信号混合和频谱分析

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法       神经网络预测       雷达通信       无线传感器        电力系统

信号处理              图像处理               路径规划       元胞自动机        无人机 

⛄ 内容介绍

​现阶段,我国数字信号处理与仿真技术正在逐步的发展,成为了一门新兴学科,并以其自身独特的特点对其他学科进行影响.不仅如此,数字信号处理与仿真技术与我国国民经济的发展存在着密切的联系.它的应用使我们的生产生活发生了翻天覆地变化.本文从数字信号处理与仿真的相关概念出发,系统的阐述了基于MATLAB下的数字信号处理与仿真技术.

⛄ 部分代码

function varargout = signal_gui(varargin)

% SIGNAL_GUI MATLAB code for signal_gui.fig

%      SIGNAL_GUI, by itself, creates a new SIGNAL_GUI or raises the existing

%      singleton*.

%

%      H = SIGNAL_GUI returns the handle to a new SIGNAL_GUI or the handle to

%      the existing singleton*.

%

%      SIGNAL_GUI('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in SIGNAL_GUI.M with the given input arguments.

%

%      SIGNAL_GUI('Property','Value',...) creates a new SIGNAL_GUI or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before signal_gui_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to signal_gui_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

% Edit the above text to modify the response to help signal_gui

% Last Modified by GUIDE v2.5 22-Dec-2020 14:08:59

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

                   'gui_Singleton',  gui_Singleton, ...

                   'gui_OpeningFcn', @signal_gui_OpeningFcn, ...

                   'gui_OutputFcn',  @signal_gui_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

% End initialization code - DO NOT EDIT

% --- Executes just before signal_gui is made visible.

function signal_gui_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_gui (see VARARGIN)

% Choose default command line output for signal_gui

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes signal_gui wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = signal_gui_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;

% --- Executes on button press in pushbutton6.

function pushbutton6_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton6 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

ret=questdlg('确认退出?','退出确认','yes','no','no');

if strcmp(ret,'no')

    return;

end

 close(gcf);

% --- Executes on selection change in popupmenu3.

function popupmenu3_Callback(hObject, eventdata, handles)

% hObject    handle to popupmenu3 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu3 contents as cell array

%        contents{get(hObject,'Value')} returns selected item from popupmenu3

% --- Executes during object creation, after setting all properties.

function popupmenu3_CreateFcn(hObject, eventdata, handles)

% hObject    handle to popupmenu3 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

    set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in pushbutton5.

function pushbutton5_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton5 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

fre2=get(handles.edit4,'string');

amp2=get(handles.edit5,'string');

points2=get(handles.edit6,'string');

fre2 = eval(fre2);

amp2 = eval(amp2);

points2 = eval(points2);

va2 = get(handles.popupmenu2,'Value');

str2 = get(handles.popupmenu2,'String');

switch str2{va2}

    case '正弦波'  

        fs = 100;

        N2 = points2;

        n2 = 0:N2-1;

        t2 = n2/fs;

        x2 = amp2*sin(2*pi*fre2*t2);

    case '方波'

        fs = 100;

        N2 = points2;

        n2 = 0:N2-1;

        t2 = n2/fs;

        x2 = amp2*square(2*pi*fre2*t2,50);

    case '三角波'           

        fs = 100;

        N2 = points2;

        n2 = 0:N2-1;

        t2 = n2/fs;

        x2 = amp2*sawtooth(2*pi*fre2*t2,0.5);

end

fre1=get(handles.edit1,'string');

amp1=get(handles.edit2,'string');

points1=get(handles.edit3,'string');

fre1 = eval(fre1);

amp1 = eval(amp1);

points1 = eval(points1);

val = get(handles.popupmenu1,'Value');

str = get(handles.popupmenu1,'String');

switch str{val}

    case '正弦波'  

        fs = 100;

        N1 = points1;

        n1 = 0:N1-1;

        t1 = n1/fs;

        x1 = amp1*sin(2*pi*fre1*t1);

    case '方波'

        fs = 100;

        N1 = points1;

        n1 = 0:N1-1;

        t1 = n1/fs;

        x1 = amp1*square(2*pi*fre1*t1,50);

    case '三角波'           

        fs = 100;

        N1 = points1;

        n1 = 0:N1-1;

        t1 = n1/fs;

        x1 = amp1*sawtooth(2*pi*fre1*t1,0.5);

end

axes(handles.axes3);

cla reset;

va2 = get(handles.popupmenu3,'Value');

str2 = get(handles.popupmenu3,'String');

switch str2{va2}

    case '加'

        if length(x1)>length(x2)

            t = t1;

            x = x1+x2;

            plot(t,x,'r');

            xlabel('时间');

            ylabel('信号');

        else

            t = t2;

            x = x1+x2;

            plot(t,x,'r');

            xlabel('时间');

            ylabel('信号');

        end

    case '减'

        if length(x1)>length(x2)

            t = t1;

            x = x1-x2;

            plot(t,x,'r');

            xlabel('时间');

            ylabel('信号');

        else

            t = t2;

            x = x1-x2;

            plot(t,x,'r');

            xlabel('时间');

            ylabel('信号');

        end

    case '乘'

        if length(x1)>length(x2)

            t = t1;

            x = x1.*x2;

            plot(t,x,'r');

            xlabel('时间');

            ylabel('信号');

        else

            t = t2;

            x = x1.*x2;

            plot(t,x,'r');

            xlabel('时间');

            ylabel('信号');

        end

    case '除'

        if length(x1)>length(x2)

            t = t1;

            x = x1./x2;

            plot(t,x,'r');

            xlabel('时间');

            ylabel('信号');

        else

            t = t2;

            x = x1./x2;

            plot(t,x,'r');

            xlabel('时间');

            ylabel('信号');

        end

end

guidata(hObject,handles);

% --- Executes on selection change in popupmenu1.

function popupmenu1_Callback(hObject, eventdata, handles)

% hObject    handle to popupmenu1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array

%        contents{get(hObject,'Value')} returns selected item from popupmenu1

% --- Executes during object creation, after setting all properties.

function popupmenu1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to popupmenu1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

    set(hObject,'BackgroundColor','white');

end

function edit1_Callback(hObject, eventdata, handles)

% hObject    handle to edit1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text

%        str2double(get(hObject,'String')) returns contents of edit1 as a double

guidata(hObject,handles);

⛄ 运行结果

⛄ 参考文献

[1] 杨峰, 苏玉萍, 余冬菊. 用MATLAB模拟实现数字信号的调制与频谱分析[J]. 电脑学习, 2008.

[2] 王靖斌. 基于MATLAB的数字信号处理的模拟与仿真[J].  2008.

[3] 钟丽辉, 戴正权, 李莎. 基于MATLAB的工程实践性"数字信号处理"实验改革初探[J]. 工业和信息化教育, 2016(12):6.

⛳️ 代码获取关注我

❤️部分理论引用网络文献,若有侵权联系博主删除

❤️ 关注我领取海量matlab电子书和数学建模资料

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
PSPICE和MATLAB是两种常用的综合电路仿真和分析工具,它们都具有各自独特的特点和广泛的应用领域。 PSPICE是一款由美国电子设计公司Cadence设计的大型电路仿真软件,它可以进行模拟电路的建模、仿真和分析,支持包括直流、交流、数字混合信号电路在内的多种电路类型,具有良好的仿真精度和稳定性,并且可以进行多种分析,如直流工作点分析、交流分析、时域分析、频域分析等。PSPICE的建模操作简单、直观,可以进行元器件的参数设置和虚拟实验环境的构建,便于学生和工程师进行电路实验和设计。 MATLAB是一种数学计算和工程建模软件,广泛应用于各种学科领域,包括信号处理、控制系统、通信、图像处理等。对于电路仿真和分析MATLAB可以通过Simulink进行模型建立和仿真,也可以进行基于数学模型的电路分析,还可以进行数据可视化和结果分析MATLAB具有高效、精确和灵活的特点,支持多种仿真算法和工具箱,可用于电路的稳态分析、动态响应分析频谱分析等。 两者各有所长,PSPICE的重点在于电路仿真,MATLAB的重点在于数据分析和科学计算,但它们也可相互结合,进行更加全面和深入的电路仿真和分析。PSPICE和MATLAB的应用领域广泛,包括电子电路设计、嵌入式系统开发、通信系统设计、光电系统设计、医学工程等。 总之,综合电路仿真与分析是电子工程、电气工程和计算科学等多个学科的重要内容,PSPICE和MATLAB都是电路仿真和分析的优秀工具,具有广泛的应用价值和发展前景。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab科研辅导帮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值