function varargout = Signal_Display(varargin)
% SIGNAL_DISPLAY MATLAB code for Signal_Display.fig
% SIGNAL_DISPLAY, by itself, creates a new SIGNAL_DISPLAY or raises the existing
% singleton*.
%
% H = SIGNAL_DISPLAY returns the handle to a new SIGNAL_DISPLAY or the handle to
% the existing singleton*.
%
% SIGNAL_DISPLAY('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SIGNAL_DISPLAY.M with the given input arguments.
%
% SIGNAL_DISPLAY('Property','Value',...) creates a new SIGNAL_DISPLAY or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Signal_Display_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Signal_Display_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_Display
% Last Modified by GUIDE v2.5 19-Oct-2018 20:12:50
% Begin initialization codeglobal grid_enable = 1; - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Signal_Display_OpeningFcn, ...
'gui_OutputFcn', @Signal_Display_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_Display is made visible.
function Signal_Display_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_Display (see VARARGIN)
% Choose default command line output for Signal_Display
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Signal_Display wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Signal_Display_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 pushbutton1.
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)
plot_sty=get(handles.popupmenu1,'value');%信号类型
A=str2num(get(handles.edit1,'String'));
w=str2num(get(handles.edit2,'String'));
p=str2num(get(handles.edit3,'String'));
color_num=get(handles.popupmenu2,'value');%获取信号图像颜色
line_type_num=get(handles.popupmenu3,'value');%获取信号图像线型
vertex_ticks_num=get(handles.popupmenu4,'value');%获取信号图像顶点标记
color = ['k','b','g','r','c','m','y','w'];%颜色存储
line_type = ['-',':','-.','--'];%线型存储
vertex_ticks = [' ','.','o','x','+','*','s','d','v','^','<','>','p','h'];%顶点标记存储
signal_type= [color(color_num),line_type(line_type_num),vertex_ticks(vertex_ticks_num)];
clv = join(signal_type);%数组合成plot函数参数
t_min = str2num(get(handles.edit4,'String'));%t取值上下限
t_max = str2num(get(handles.edit5,'String'));%
x_min = str2num(get(handles.edit6,'String'));%X轴取值范围上下限
x_max = str2num(get(handles.edit7,'String'));%
y_min = str2num(get(handles.edit8,'String'));%Y轴取值范围上下限
y_max = str2num(get(handles.edit9,'String'));%
t = t_min:0.01:t_max;
index_num = str2num(get(handles.edit10,'String'));%指数值
gate_width = str2num(get(handles.edit11,'String'));%门函数宽度
line_width = str2num(get(handles.edit12,'String'));%图像线宽
sawtooth_wave_T = str2num(get(handles.edit13,'String'));%锯齿波函数周期
global grid_enable;%显示网格使能标志位
switch(plot_sty)
case 1%正弦信号
y=A*sin(w*t+p);
plot(t,y,clv ,'linewidth',line_width);
title('sin');
if(grid_enable == 1)
grid on;
else
grid off;
end
axis([x_min,x_max,-A+y_min,A+y_max]);
case 2%余弦信号
y=A*cos(w*t+p);
plot(t,y,clv ,'linewidth',line_width);
title('cos');
if(grid_enable == 1)
grid on;
else
grid off;
end
axis([x_min,x_max,-A+y_min,A+y_max]);
case 3%指数函数
y=exp(index_num*t);
plot(t,y,clv,'linewidth',line_width);
title('指数函数图像')
if(grid_enable == 1)
grid on;
else
grid off;
end
axis([x_min,x_max,-A+y_min,A+y_max]);
case 4%门函数
f=rectpuls(t,gate_width);
plot(t,f,clv,'linewidth',line_width);
title('门函数的波形');
if(grid_enable == 1)
grid on;
else
grid off;
end
axis([x_min,x_max,-A+y_min,A+y_max]);
case 5%锯齿波函数
f=sawtooth(2*pi/sawtooth_wave_T*t,0);
plot(t,f,clv,'linewidth',line_width);
title('锯齿波函数的波形');
if(grid_enable == 1)
grid on;
else
grid off;
end
axis([x_min,x_max,-A+y_min,A+y_max]);
case 6%抽样函数
t1=t/pi;
f=sinc(t1);
plot(t,f,clv,'linewidth',line_width);
title('抽样信号');
if(grid_enable == 1)
grid on;
else
grid off;
end
axis([x_min,x_max,-A+y_min,A+y_max]);
line([x_min,x_max],[0,0],'color','k');
case 7%阶跃函数
f = stepfun(t,0);
plot(t,f,clv,'linewidth',line_width);
title('阶跃信号');
if(grid_enable == 1)
grid on;
else
grid off;
end
axis([x_min,x_max,-A+y_min,A+y_max]);
case 8%指数衰减的正弦信号
f=2*exp(index_num*t).*sin(w*t+p);
plot(t,f,clv,'linewidth',line_width);
title('指数衰减的正弦信号');
if(grid_enable == 1)
grid on;
else
grid off;
end
f2=2*exp(index_num*t);%包络线函数
f3=-2*exp(index_num*t);
signal_type= [color(color_num),line_type(2),vertex_ticks(vertex_ticks_num)];%保证包络线为虚线
clv = join(signal_type);%包络线 数组合成plot函数参数
hold on;
plot(t,f2,clv,'linewidth',line_width);
hold on;
plot(t,f3,clv,'linewidth',line_width);
hold off;%保证继续绘制其他图像
axis([x_min,x_max,-A+y_min,A+y_max]);
case 9%正弦序列
t = t_min:0.1:t_max;
f=A*sin(w*t);
stem(t,f,color(color_num),'linewidth',line_width);
if(grid_enable == 1)
grid on;
else
grid off;
end
axis([x_min,x_max,-A+y_min,A+y_max]);
title('正弦序列');
line([x_min,x_max],[0,0],'color','k');%绘制横坐标
case 10%余弦序列
t = t_min:0.1:t_max;
f=A*cos(w*t);
stem(t,f,color(color_num),'linewidth',line_width);
if(grid_enable == 1)
grid on;
else
grid off;
end
axis([x_min,x_max,-A+y_min,A+y_max]);
title('余弦序列');
line([x_min,x_max],[0,0],'color','k');%绘制横坐标
case 11%指数序列
t = t_min:0.2:t_max;
f=exp(i