⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 homework3.m

📁 对输入的一有理Z变换表达式(输入分子和分母系数序列)
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = Homework3(varargin)
% HOMEWORK3 M-file for Homework3.fig
%      HOMEWORK3, by itself, creates a new HOMEWORK3 or raises the existing
%      singleton*.
%
%      H = HOMEWORK3 returns the handle to a new HOMEWORK3 or the handle to
%      the existing singleton*.
%
%      HOMEWORK3('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in HOMEWORK3.M with the given input arguments.
%
%      HOMEWORK3('Property','Value',...) creates a new HOMEWORK3 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Homework3_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Homework3_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 Homework3

% Last Modified by GUIDE v2.5 15-Oct-2005 06:00:20
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Homework3_OpeningFcn, ...
                   'gui_OutputFcn',  @Homework3_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
% End initialization code - DO NOT EDIT


% --- Executes just before Homework3 is made visible.
function Homework3_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 Homework3 (see VARARGIN)

% Choose default command line output for Homework3
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Homework3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Homework3_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 during object creation, after setting all properties.function NumEditor_CreateFcn(hObject, eventdata, handles)% hObject    handle to NumEditor (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction NumEditor_Callback(hObject, eventdata, handles)% hObject    handle to NumEditor (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of NumEditor as text%        str2double(get(hObject,'String')) returns contents of NumEditor as a double
global Modifiedset(handles.ZPButton, 'Enable', 'off');
set(handles.ROCList, 'Enable', 'off');set(handles.DTFTButton, 'Enable', 'off');
set(handles.NumFreqEditor, 'Enable', 'off');
set(handles.DrawSeqButton, 'Enable', 'off');
set(handles.SeqNumEditor, 'Enable', 'off');
Modified = 1;
% --- Executes during object creation, after setting all properties.function DenEditor_CreateFcn(hObject, eventdata, handles)% hObject    handle to DenEditor (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction DenEditor_Callback(hObject, eventdata, handles)% hObject    handle to DenEditor (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of DenEditor as text%        str2double(get(hObject,'String')) returns contents of DenEditor as a double
global Modifiedset(handles.ZPButton, 'Enable', 'off');
set(handles.ROCList, 'Enable', 'off');
set(handles.DTFTButton, 'Enable', 'off');
set(handles.NumFreqEditor, 'Enable', 'off');
set(handles.DrawSeqButton, 'Enable', 'off');
set(handles.SeqNumEditor, 'Enable', 'off');
Modified = 1;
% --- Executes during object creation, after setting all properties.function ROCList_CreateFcn(hObject, eventdata, handles)% hObject    handle to ROCList (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: listbox controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on selection change in ROCList.function ROCList_Callback(hObject, eventdata, handles)% hObject    handle to ROCList (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns ROCList contents as cell array%        contents{get(hObject,'Value')} returns selected item from ROCList
value = get(hObject, 'Value');
judge_InterfaceControl(value, handles);

% 根据ROC的选项来控制界面属性
function judge_InterfaceControl(value, handles)  
global absp DiffPoleNum
flag = 0;
if value == 1
    if isempty(absp) || absp(1) > 1
        flag = 1;
    end
elseif value == DiffPoleNum + 1
    if absp(DiffPoleNum) < 1 - 5e-15
        flag = 1;
    end
else
    if absp(value-1) < 1-5e-15 && absp(value) > 1+5e-15
        flag = 1;
    end
end

if flag == 1
    set(handles.Prompt, 'String', strvcat('Your selected  ROC includs unit circle.', 'Please click the button to show', 'magnitude  &  phase map on unit circle'));

    set(handles.DTFTButton, 'Enable', 'on');
    set(handles.NumFreqEditor, 'Enable', 'on');
else
     set(handles.Prompt, 'String', strvcat('Your selected  ROC does NOT includs unit circle.', 'magnitude  &  phase map on unit circle have no meaning'));

    set(handles.DTFTButton, 'Enable', 'off');
    set(handles.NumFreqEditor, 'Enable', 'off');
end
set(handles.DrawSeqButton, 'Enable', 'on');
if get(handles.SetLengthCheckbox, 'Value') == 1
    set(handles.SeqNumEditor, 'Enable', 'on');
else
    set(handles.SeqNumEditor, 'Enable', 'off');
end
% --- Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: listbox controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on selection change in edit3.function edit3_Callback(hObject, eventdata, handles)% hObject    handle to edit3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns edit3 contents as cell array%        contents{get(hObject,'Value')} returns selected item from edit3% --- Executes on button press in DrawSeqButton.function DrawSeqButton_Callback(hObject, eventdata, handles)% hObject    handle to DrawSeqButton (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)

global Num Den z p k DiffPoleNum absp outputFlag 
len = 0;
if get(handles.SetLengthCheckbox, 'Value') == 1
    len = str2double(get(handles.SeqNumEditor, 'String'));  
end
value = get(handles.ROCList,'Value');

if value == 1
    % untilize the time-shift property of Z transform to calculate
    %   left-side sequence
    num1 = fliplr(Num);
    den1 = fliplr(Den);
    if (len > 0)
        [y,t] = impz(num1, den1, len);
    else
        [y,t] = impz(num1, den1);
    end
    t = -t;
    title_str = 'Left side sequence';
elseif value == DiffPoleNum + 1
    if (len > 0)
        [y,t] = impz(Num, Den, len);
    else
        [y,t] = impz(Num, Den);
    end
    title_str = 'Right side sequence';
else
    
    [R,P,K] = residuez(Num, Den);
    [y, t] = InvZTrans(R, P, K, absp(value), len);
    title_str = 'Double side sequence';
end

if (outputFlag)
    disp(title_str); disp(y);
    disp('Time;');disp(t);
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -