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

📄 performprony.m

📁 prony matlab toolbox
💻 M
📖 第 1 页 / 共 4 页
字号:
function varargout = performprony(varargin)
% PERFORMPRONY M-file for performprony.fig
%      PERFORMPRONY, by itself, creates a new PERFORMPRONY or raises the existing
%      singleton*.
%
%      H = PERFORMPRONY returns the handle to a new PERFORMPRONY or the handle to
%      the existing singleton*.
%
%      PERFORMPRONY('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PERFORMPRONY.M with the given input arguments.
%
%      PERFORMPRONY('Property','Value',...) creates a new PERFORMPRONY or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before performprony_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to performprony_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 performprony

% Last Modified by GUIDE v2.5 06-Jul-2003 20:56:09
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @performprony_OpeningFcn, ...
                   'gui_OutputFcn',  @performprony_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 performprony is made visible.
function performprony_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 performprony (see VARARGIN)

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


% Set the background of the figure to Black
% Set the background of the figure to Black
%whitebg('white');
%colordef white;
set(hObject,'Color','white');
% Have the toolbar
pronytoolbar(hObject,'on');
% Flag to check if the user has saved any session
handles.menu_saveflag=0;
handles.menu_saveasflag=0;
handles.test_time=evalin('base','PronyData.dp_x');
handles.test_data=evalin('base','PronyData.dp_y');
handles.criteria_val = get(handles.ppmenu_criteria,'Value');
% Set the starting colors of axes as black
%set(handles.axes_pronyfit,'XColor','k');
%set(handles.axes_pronyfit,'YColor','k');
%set(handles.axes_modesfit,'XColor','k');
%set(handles.axes_modesfit,'YColor','k');
%set(handles.axes_seerror,'XColor','k');
%set(handles.axes_seerror,'YColor','k');
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes performprony wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = performprony_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;
 %set(hObject,'BackgroundColor',[0.5 0.5 0.5]);% --- Executes on button press in rdbutton_mordertime.
function rdbutton_mordertime_Callback(hObject, eventdata, handles)
% hObject    handle to rdbutton_mordertime (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rdbutton_mordertime
mutual_exclude(handles.rdbutton_morderfreq) ;


% --- Executes on button press in rdbutton_morderfreq.
function rdbutton_morderfreq_Callback(hObject, eventdata, handles)
% hObject    handle to rdbutton_morderfreq (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rdbutton_morderfreq
mutual_exclude(handles.rdbutton_mordertime) ;


% --- Executes on button press in push_morder.
function push_morder_Callback(hObject, eventdata, handles)
% hObject    handle to push_morder (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
setstatus(gcbf,'Choose "Model Order Selection" Criteria');
set([handles.rdbutton_time,handles.rdbutton_frequency,handles.ppmenu_criteria,handles.edittxtmodes],'enable','on');
set(handles.ppmenu_modesfit,'enable','on');
% Set the default for model order graphic mode as time domain
if (get(handles.rdbutton_morderfreq,'Value') == get(handles.rdbutton_morderfreq,'Min'))
    set(handles.rdbutton_mordertime,'Value',1);
end
FirstResults=save_FirstResults(handles);
axes(handles.axes_pronyfit);
    % implement time domain prony
    if (get(handles.rdbutton_mordertime,'Value') == get(handles.rdbutton_mordertime,'Max'))
        plot(handles.test_time,FirstResults.iapp,'r',handles.test_time,handles.test_data,'b');xlabel('Time');
        ylabel('Signal');
        title(sprintf('Prony Analysis of Model Order %d in Time Domain',FirstResults.NewVal))
        legend('Prony Approximate', 'Measured')
    end
     % implement frequency domain prony
     if (get(handles.rdbutton_morderfreq,'Value') == get(handles.rdbutton_morderfreq,'Max'))
        [f,fft_data_plot,fft_iapp_plot]= fft_analysis(handles.test_time,handles.test_data,FirstResults.iapp);
        plot(f,fft_iapp_plot,'r',f,fft_data_plot,'b');xlabel('Frequency');
        ylabel('  Magnitude (dB)  ');
        title(sprintf('Prony Analysis of Model Order %d in Frequency Domain',FirstResults.NewVal))
        legend('Prony Approximate', 'Measured')
    end


function[FirstResults]= save_FirstResults(handles)
    NewVal=fetch_NewVal(handles);
    [iapp,ai,a_list,tau_list,omega_list,SUB_IND,energy,p]=applyprony(handles.test_time,handles.test_data,NewVal,0,1);
    FirstResults =struct('NewVal',[],'iapp',[],'ai',[],...
		             'a_list',[],'tau_list',[],'omega_list',[],...
                     'SUB_IND',[],'energy',[],'p',[]);
    FirstResults.NewVal=NewVal;
    FirstResults.iapp = iapp;
    FirstResults.a_list=a_list;
    FirstResults.tau_list=tau_list;
    FirstResults.omega_list=omega_list;
    FirstResults.SUB_IND=SUB_IND;
    FirstResults.energy=energy;
    FirstResults.p=p;
    FirstResults.ai=ai;


function mutual_exclude(off)
    set(off,'Value',0)% --- Executes on button press in rdbutton_time.function rdbutton_time_Callback(hObject, eventdata, handles)% hObject    handle to rdbutton_time (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of rdbutton_timemutual_exclude(handles.rdbutton_frequency) ;% --- Executes on button press in rdbutton_frequency.function rdbutton_frequency_Callback(hObject, eventdata, handles)% hObject    handle to rdbutton_frequency (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of rdbutton_frequencymutual_exclude(handles.rdbutton_time) ;% --- Executes during object creation, after setting all properties.function ppmenu_criteria_CreateFcn(hObject, eventdata, handles)% hObject    handle to ppmenu_criteria (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end
% --- Executes on button press in push_mode.
function push_mode_Callback(hObject, eventdata, handles)
% hObject    handle to push_mode (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.criteria_val = get(handles.ppmenu_criteria,'Value');
 guidata(hObject,handles); % store the changes
 % Set the default for modes selection graphic mode as time domain
if (get(handles.rdbutton_frequency,'Value') == get(handles.rdbutton_frequency,'Min'))
    set(handles.rdbutton_time,'Value',1);
end
PronyResults=getPronyResults(handles);
promptstr=perform_resultslist(handles.test_time,handles.test_data,PronyResults.NewVal,PronyResults.SUB_N,handles.criteria_val);
set(handles.lstbx_numeric,'String',promptstr); 
perform_plotcriteria(handles,PronyResults);
set(handles.ppmenu_modesfit,'Value',1);
set(handles.lstbx_numeric,'Value',1);

% --- Executes on selection change in ppmenu_criteria.function ppmenu_criteria_Callback(hObject, eventdata, handles)% hObject    handle to ppmenu_criteria (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 ppmenu_criteria contents as cell array%        contents{get(hObject,'Value')} returns selected item from ppmenu_criteria
%-------------------------------------------------------------
function perform_plotcriteria(handles,Results)
    switch handles.criteria_val
    case 1 % User selects Residue Amplitude Criteria
        if (get(handles.rdbutton_time,'Value') == get(handles.rdbutton_time,'Max'));
            prony_time(handles,Results);
        elseif(get(handles.rdbutton_frequency,'Value') == get(handles.rdbutton_frequency,'Max'));
            prony_frequency(handles,Results);
        else
            set(handles.rdbutton_time,'Value',1);
            prony_time(handles,Results);
        end
    
    case 2 % Minimum Energy Criteria
        if (get(handles.rdbutton_time,'Value') == get(handles.rdbutton_time,'Max'));
            prony_time(handles,Results);
        elseif(get(handles.rdbutton_frequency,'Value') == get(handles.rdbutton_frequency,'Max'));
            prony_frequency(handles,Results);
        else
            set(handles.rdbutton_time,'Value',1);
            prony_time(handles,Results);
        end
    end    
     axes(handles.axes_seerror);
     FirstResults=save_FirstResults(handles);
     choose_pronyplots(handles,Results,FirstResults)
     
function choose_pronyplots(handles,Results,FirstResults)
    pp_val = get(handles.ppmenu_pronyplots,'Value');
    sqerror=(handles.test_data(:)-Results.ai(:)).^2;
    % Compute the normalized mean squared error
    nmse=sum(sqerror)/size(sqerror,1);
    set(handles.edit_mse,'String',nmse);
    switch pp_val
    case 1% Squared Error
        seerror(handles,Results);
    case 2  % User selects Poles Plot
        polesplot(handles,Results);
    case 3 % Sorted Residues
        Resplot(handles,Results);
    case 4 % pole zero
        PZplot(handles,Results);

⌨️ 快捷键说明

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