原创 matlab GUI设计

2008-7-7 10:03 3464 5 5 分类: 处理器与DSP

能产生正弦信号、方波、三角波


源代码如下:


function varargout = Mytools(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Mytools_OpeningFcn, ...
                   'gui_OutputFcn',  @Mytools_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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
function Mytools_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = Mytools_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
t=0:0.001:6;
y=sin(0.5*pi*t);
plot(t,y);
title('正弦信号');
grid on;
axis([-0.5 6.2 -1.2 1.2]);
set(handles.text1,'String',' 说明:周期为4,幅值为2的正弦波信号');
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function pushbutton8_Callback(hObject, eventdata, handles)
function pushbutton10_Callback(hObject, eventdata, handles)
t=0:0.001:3;
y=square(2*pi*t,50);
plot(t,y);
grid on;
axis([0,3,-1.2,1.2]);
title('方波信号');
set(handles.text1,'String',' 说明:周期为1,幅值为2的方波信号');
function pushbutton9_Callback(hObject, eventdata, handles)
t=-6:0.01:6;
ft=sawtooth(pi*t,0.5);
plot(t,ft);
grid on;
title('三角波信号');
axsi([-6 6 -1.2 1.2]);
set(handles.text1,'String',' 说明:周期为2,幅值为2的三角波信号');


点击开大图


 

文章评论0条评论)

登录后参与讨论
我要评论
0
5
关闭 站长推荐上一条 /2 下一条