【信号分析】基于matlab的信号分析附GUI界面

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

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

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

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

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

⛄ 内容介绍

本文主要介绍基于MATLAB GUI的信号分析仪的设计,使用MATLAB图形用户界面中的各种控件来实现对参数的设定并最终显示信号波形曲线图.此分析仪能够输出的曲线图有时域曲线,复域曲线,频域曲线以及时域曲线与频域曲线的对比,使得能够准确的观察时域曲线与频域曲线的同步变化情况.

⛄ 部分代码

function varargout = juli(varargin)

% JULI M-file for juli.fig

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

%      singleton*.

%

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

%      the existing singleton*.

%

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

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

%

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

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

%      applied to the GUI before juli_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

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

% Last Modified by GUIDE v2.5 28-May-2008 19:12:14

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

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

                   'gui_Singleton',  gui_Singleton, ...

                   'gui_OpeningFcn', @juli_OpeningFcn, ...

                   'gui_OutputFcn',  @juli_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 juli is made visible.

function juli_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 juli (see VARARGIN)

% Choose default command line output for juli

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

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

% uiwait(handles.figure1);

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

function varargout = juli_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 selection change in listbox1.

function listbox1_Callback(hObject, eventdata, handles)

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

switch val

case 1

  t=-1:0.01:10;

  y1=sin(2*pi*t);

  axes(handles.axes1);

plot(t,y);

case 2

     t=-1:0.01:10;

  y1=cos(2*pi*t);

  axes(handles.axes1);

plot(t,y);

case 3

    t=-1:0.01:10;

    y1=square(2*pi*t);

    axes(handles.axes1);

plot(t,y);

case 4

        t=-1:0.01:10;

  axes(handles.axes1);

y1=sawtooth(2*pi*t);

plot(t,y);

case 5

    t=-3:0.001:5;

    axes(handles.axes1);

y1=tripuls(t,4,0.5);

plot(t,y);

  

end

% hObject    handle to listbox1 (see GCBO)

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

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

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

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

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

function listbox1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to listbox1 (see GCBO)

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

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

% Hint: listbox 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 pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

  t=-3:0.1:10;

hfstext=findobj('tag','edit1');

h=get(hfstext,'string');

w=str2num(h);

axes(handles.axes2);

y=sin(w*t);

plot(t,y);

% hObject    handle to pushbutton1 (see GCBO)

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

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

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles)

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

switch val

case 1

  t=0:0.1:10;

  hfstext=findobj('tag','edit1');

h=get(hfstext,'string');

w=str2num(h);

y=sin(w*t);

  

  y1=sin(2*pi*t);

  y2=y.*y1

  axes(handles.axes3);

plot(t,y2);

case 2

     t=0:0.01:10;

  y1=cos(2*pi*t);

   hfstext=findobj('tag','edit1');

h=get(hfstext,'string');

w=str2num(h);

y=sin(w*t);

     y2=y.*y1

  axes(handles.axes3);

plot(t,y);

case 3

    t=0:0.01:10;

    y1=square(2*pi*t);

   hfstext=findobj('tag','edit1');

h=get(hfstext,'string');

w=str2num(h);

y=sin(w*t);

       y2=y.*y1

    axes(handles.axes3);

plot(t,y);

case 4

        t=0:0.01:10;

  

y1=sawtooth(2*pi*t);

 hfstext=findobj('tag','edit1');

h=get(hfstext,'string');

w=str2num(h);

y=sin(w*t);

  y2=y.*y1

 axes(handles.axes3);

plot(t,y);

case 5

    t=-3:0.001:5;

   

 hfstext=findobj('tag','edit1');

h=get(hfstext,'string');

w=str2num(h);

y=sin(w*t);

y1=tripuls(t,4,0.5);

  y2=y.*y1

  axes(handles.axes3);

  

plot(t,y);

xlabel('时间(t)');

title('正弦信号');

  

end

% hObject    handle to pushbutton2 (see GCBO)

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

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

% --- Executes on selection change in popupmenu1.

function popupmenu1_Callback(hObject, eventdata, handles)

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

switch val

case 1

  t=0:0.01:10;

  y=sin(2*pi*t);

  axes(handles.axes1);

plot(t,y);

xlabel('时间(t)');

title('正弦信号');

case 2

     t=0:0.01:10;

  y=cos(2*pi*t);

  axes(handles.axes1);

plot(t,y);

xlabel('时间(t)');

title('余弦信号');

case 3

    t=0:0.01:10;

    y=square(2*pi*t);

    axes(handles.axes1);

plot(t,y);

xlabel('时间(t)');

title('周期方波信号');

case 4

        t=0:0.01:10;

  axes(handles.axes1);

y=sawtooth(2*pi*t);

plot(t,y);

xlabel('时间(t)');

title('周期锯齿波信号');

case 5

    t=-3:0.001:5;

    axes(handles.axes1);

y=tripuls(t,4,0.5);

plot(t,y);

xlabel('时间(t)');

title('三角波信号');

  

end

% 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 = 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

% --- Executes on slider movement.

function slider1_Callback(hObject, eventdata, handles)

fs=get(hObject,'value');

hfstext=findobj('tag','edit1');

set(hfstext,'string',num2str(fs));

% hObject    handle to slider1 (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,'Value') returns position of slider

%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

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

function slider1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to slider1 (see GCBO)

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

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

% Hint: slider controls usually have a light gray background.

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

    set(hObject,'BackgroundColor',[.9 .9 .9]);

end

function edit1_Callback(hObject, eventdata, handles)

fs=get(hObject,'value');

hfs=findobj('tag','slider1');

set(hfs,'string',num2str(fs));

% 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

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

function edit1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to edit1 (see GCBO)

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

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

% Hint: edit 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 pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles)

close;

main

% hObject    handle to pushbutton3 (see GCBO)

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

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

% --- Executes on button press in checkbox1.

function checkbox1_Callback(hObject, eventdata, handles)

r=get(hObject,'value');

if r==1

    

    grid on

else

    grid off

end

% hObject    handle to checkbox1 (see GCBO)

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

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

% Hint: get(hObject,'Value') returns toggle state of checkbox1

% --- Executes on button press in checkbox2.

function checkbox2_Callback(hObject, eventdata, handles)

r=get(hObject,'value');

if r==1

    

 zoom on

else

   zoom off

end

% hObject    handle to checkbox2 (see GCBO)

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

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

% Hint: get(hObject,'Value') returns toggle state of checkbox2

⛄ 运行结果

⛄ 参考文献

[1] 陈瑞峰, 左曙光, 郭伟. 基于MATLAB GUI的信号分析系统[J]. 佳木斯大学学报:自然科学版, 2009, 27(5):4.

[2] 赵秋英, 吴玲, 徐秀丽. 基于MATLAB GUI的信号分析仪设计[J]. 中国科技博览, 2015(004):000.

⛳️ 代码获取关注我

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

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
您好!Matlab提供了丰富的GUI设计工具,可以方便地实现信号分析和处理程序。下面是一个简单的例子,帮助您入门。 首先,打开Matlab软件,点击 "APPS",选择 "GUIDE",打开GUI设计工具。在 "File" 菜单中选择 "New GUI",选择 "Blank GUI",创建一个新的GUI界面。 在GUI界面中添加一些控件,比如按钮、文本框、列表框等,可以通过 "Palette" 按钮来添加。在本例中,我们添加一个文本框和一个按钮。 接下来,我们需要编写一些代码来实现信号分析和处理功能。点击 "CODE",打开回调函数编辑器,输入以下代码: ```matlab function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Read signal from text box signal_str = get(handles.edit1, 'String'); signal = str2double(strsplit(signal_str, ',')); % Calculate signal statistics mean_val = mean(signal); max_val = max(signal); min_val = min(signal); std_val = std(signal); % Display results in message box msgbox(sprintf('Mean: %f\nMax: %f\nMin: %f\nStd: %f', mean_val, max_val, min_val, std_val)); ``` 这段代码实现了一个简单的功能:读取文本框中输入的信号,计算信号的平均值、最大值、最小值和标准差,并在消息框中显示结果。 保存代码并返回GUI界面。双击按钮控件,打开按钮的回调函数编辑器,将 "pushbutton1_Callback" 函数与按钮的 "Callback" 属性关联起来。 现在,您可以运行GUI程序了。输入一组信号数据,用逗号隔开,点击按钮,程序将计算信号的统计信息并显示在消息框中。 这只是一个简单的例子,您可以根据自己的需求,添加更多控件和编写更复杂的代码来实现更强大的信号分析和处理功能。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

matlab科研助手

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

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

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

打赏作者

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

抵扣说明:

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

余额充值