题目分析:
要求z变换与s变换的关系,首先考虑z变换与s变换之间运用领域的不同,s域是连续时间表示域,使用连续的时间变量s表示信号的自变量,取值范围为复平面上的所有点。而z域是离散时间表示域,使用离散的时间变量z表示信号的 自变量取值范围虽然也为复平面上的所有点,但对于离散信号而言,主要在单位圆内取值。
另外,从s域到z域的变换关系是通过采样操作实现的,具体关系如下:
- 采样操作:将连续时间信号进行采样,得到离散时间信号。采样操作可以用冲激函数序列来表示,即将连续时间信号乘以冲激函数序列。
- 傅里叶变换:对连续时间信号进行傅里叶变换,得到信号在频域上的表示,即s域表示。
- Z变换:对离散时间信号进行z变换,得到信号在频域上的表示,即z域表示。
设计思路:
首先设置一个列表框,列出输入信号,这里我设置了一个阶跃信号一个冲激信号,之后设置一个按钮与五个轴,在第一个轴中运用heaviside与stem
函数画出离散的阶跃函数,然后在第二个轴中用ztrans函数进行z变换,在第三个轴中用laplace函数进行拉普拉斯变换,随后再定义两个轴用于存放各自变换的定义域,从图中可以看到z变换的收敛域是在单位圆内,而s变换的收敛域是在y轴左边,这是因为对于离散时间系统来说,系统的稳定性要求系统函数的极点位于单位圆内,而对于连续时间系统来说,系统的稳定性要求系统函数的极点位于s平面的左半部分,因此收敛域通常位于轴线的左侧。
而z变换与s变换间数值关系经过推导可知s变换与z变换间关系:z=e^sT
界面设计结果
代码实现
function varargout = untitled1(varargin)
% UNTITLED1 MATLAB code for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
% singleton*.
%
% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
% the existing singleton*.
%
% UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED1.M with the given input arguments.
%
% UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled1_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 untitled1
% Last Modified by GUIDE v2.5 05-Jun-2024 19:33:04
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled1_OpeningFcn, ...
'gui_OutputFcn', @untitled1_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 untitled1 is made visible.
function untitled1_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 untitled1 (see VARARGIN)
% Choose default command line output for untitled1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled1_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 popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% 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 = cellstr(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 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)
a=get(handles.popupmenu1,'Value');
syms z;
syms n;
syms t;
switch a
case 1
axes(handles.axes1);
cla;
a= -10:10;
A =heaviside(a);
stem(a, A);
xlabel('n');
ylabel('A');
title('½×Ô¾º¯Êý');
ylim([0, 2]);
yticks(0:1:2);
xticks(-10:1:10);
axes(handles.axes2);
cla
n = sym('n', 'positive');
A_z=ztrans(heaviside(n))
fplot(A_z);
title('½×Ô¾º¯ÊýµÄz±ä»»');
ylim([-5, 5]);
xlim([-5,5]);
yticks(-5:1:5);
xticks(-5:1:5);
yline(0, 'k--');
axes(handles.axes3);
cla
f=heaviside(t);
F = laplace(f)
fplot(F);
title('½×Ô¾º¯ÊýµÄs±ä»»');
ylim([-5, 5]);
xlim([-5,5]);
yticks(-5:1:5);
xticks(-5:1:5);
yline(0, 'k--');
axes(handles.axes4);
cla
theta = linspace(0, 2*pi, 1000);
x_circle = cos(theta);
y_circle = sin(theta);
fill(x_circle, y_circle, 'b', 'FaceAlpha', 0.3);
hold on;
plot(x_circle, y_circle, 'b', 'LineWidth', 2);
xlabel('ʵÖá');
ylabel('ÐéÖá');
title('z±ä»»µÄÊÕÁ²Óò');
axis([-3, 3, -3, 3]);
axis equal;
grid on;
hold off;
axes(handles.axes5);
cla
x_axis = -10:0.1:10;
y_axis = zeros(size(x_axis));
plot(x_axis, y_axis, 'k', 'LineWidth', 2);
hold on;
fill([-10,-10,0, 0], [-10, 10, 10, -10], 'r', 'FaceAlpha', 0.3);
xlabel('x');
ylabel('y');
title('s±ä»»µÄÊÕÁ²Óò');
axis([-10, 10, -10, 10]);
grid on;
hold off;
case 2
axes(handles.axes1);
cla;
x = -10:1:10;
y = zeros(size(x));
y(x == 0) = 1;
stem(x, y);
xlabel('x');
ylabel('y');
ylim([-1,2])
title('³å¼¤º¯Êý');
grid on;
axes(handles.axes2);
cla;
x=-5:1:5;
y=ones(size(x));
plot(x,y)
axes(handles.axes3);
cla;
x=-5:1:5;
y=ones(size(x));
plot(x,y)
axes(handles.axes4);
cla;
axes(handles.axes5);
cla;
end
% --- Executes during object creation, after setting all properties.
function axes3_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes3
标签:10,变换,gui,handles,untitled1,hObject,源码,matlab
From: https://blog.csdn.net/mohen_777/article/details/139766305