新闻  |   论坛  |   博客  |   在线研讨会
matlab GUI设计
0750long | 2009-06-03 10:57:26    阅读:5828   发布文章
matlab GUI设计

 

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

源代码如下:

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的三角波信号');

点击开大图

参与讨论
登录后参与讨论
推荐文章
最近访客