我是靠谱客的博主 现实牛排,最近开发中收集的这篇文章主要介绍【matlab】GUI信号发生器软面板,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

设计GUI软件界面,能够实现信号发生器软面板功能,可以产生任意参数的方波、正弦波、三角波等

面板设计如下: 

关键代码如下:

这里给出关键部分:回调函数,其他部分均为系统初始化时的内容,就不再占篇幅赘述了。
%方波函数
function pushbutton1_Callback(hObject, eventdata, handles)
A=str2num(get(handles.edit1,'string'));
w=str2num(get(handles.edit2,'string'));
z=str2num(get(handles.edit5,'string'));
fanweil=str2num(get(handles.edit6,'string'));
fanweir=str2num(get(handles.edit7,'string'));
fanweiu=str2num(get(handles.edit8,'string'));
fanweid=str2num(get(handles.edit9,'string'));
t=fanweil:0.01:fanweir;
y=A*square(w*t,z);
plot(handles.axes1,t,y);
axis([fanweil fanweir fanweiu fanweid]);
%正弦波函数
function pushbutton2_Callback(hObject, eventdata, handles)
fanweil=str2num(get(handles.edit6,'string'));
fanweir=str2num(get(handles.edit7,'string'));
fanweiu=str2num(get(handles.edit8,'string'));
fanweid=str2num(get(handles.edit9,'string'));
A=str2num(get(handles.edit1,'string'));
w=str2num(get(handles.edit2,'string'));
t=fanweil:0.01:fanweir;
y=A*sin(w*t);
plot(handles.axes1,t,y);
axis([fanweil fanweir fanweiu fanweid]);
%三角波函数
function pushbutton3_Callback(hObject, eventdata, handles)
fanweil=str2num(get(handles.edit6,'string'));
fanweir=str2num(get(handles.edit7,'string'));
fanweiu=str2num(get(handles.edit8,'string'));
fanweid=str2num(get(handles.edit9,'string'));
kuan=str2num(get(handles.edit3,'string'));
xie=str2num(get(handles.edit4,'string'));
A=str2num(get(handles.edit1,'string'));
w=str2num(get(handles.edit2,'string'));
t=fanweil:0.01:fanweir;
y=A*tripuls(w*t,kuan,xie);
plot(handles.axes1,t,y);
axis([fanweil fanweir fanweiu fanweid]);
%清空函数
function pushbutton4_Callback(hObject, eventdata, handles)
try
    delete(allchild(handles.axes1));
end
%白噪声函数
function pushbutton5_Callback(hObject, eventdata, handles)
fanweil=str2num(get(handles.edit6,'string'));
fanweir=str2num(get(handles.edit7,'string'));
fanweiu=str2num(get(handles.edit8,'string'));
fanweid=str2num(get(handles.edit9,'string'));
t=fanweil:0.01:fanweir;
y=randn(1,length(t));
plot(handles.axes1,t,y);
axis([fanweil fanweir fanweiu fanweid]);
%锯齿波函数
function pushbutton6_Callback(hObject, eventdata, handles)
fanweil=str2num(get(handles.edit6,'string'));
fanweir=str2num(get(handles.edit7,'string'));
fanweiu=str2num(get(handles.edit8,'string'));
fanweid=str2num(get(handles.edit9,'string'));
A=str2num(get(handles.edit1,'string'));
w=str2num(get(handles.edit2,'string'));
t=fanweil:0.01:fanweir;
y=A*sawtooth(w*t);
plot(handles.axes1,t,y);
axis([fanweil fanweir fanweiu fanweid]);

最后

以上就是现实牛排为你收集整理的【matlab】GUI信号发生器软面板的全部内容,希望文章能够帮你解决【matlab】GUI信号发生器软面板所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(78)

评论列表共有 0 条评论

立即
投稿
返回
顶部