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

📄 comparesessions.m

📁 Prony分析是获取系统振荡模式特征的一种非常有效的方法
💻 M
📖 第 1 页 / 共 2 页
字号:
         for index=1:Run_limit
            colorindex=mod(index,row_S);% limit colorindex to the row size of S
            % avoid zero value of colorindex, it will happen when row_
            if (colorindex==0)
                colorindex=row_S;
            end
            Run=Index_Selected(index);
            [dp_x,dp_y,ai,a_list,SUB_IND,p,energy]= preparecomparedata(SaveData,Run);
            axes(handles.axes_pole);
            index=1:size(SUB_IND,2);
            energy_size=size(energy,2);
            semilogy(index,energy,S(colorindex));
            axis([0 energy_size+1 0 1.1*max(energy)]);
            hold on;
        end
        xlabel('Index'),ylabel('Energy')
        title('Energy of Prony Modes');
        legend_seerror(handles,Index_Selected,Run_limit);
        hold off;
end % switch end

% Legend for the Poles plot
function legend_poles(handles,Index_Selected,Run_limit)
        string_matrix=sprintf('Poles Only ');
        for index=1:Run_limit
            if(Index_Selected(:)>=10)
                string_matrix=[string_matrix; sprintf('Session %d ',Index_Selected(index))];
            else
                string_matrix=[string_matrix; sprintf('Session %2d ',Index_Selected(index))];
            end
        end
        legend(string_matrix,-1);
        
% Legend for the squared error, residues and energy plot        
        
function legend_seerror(handles,Index_Selected,Run_limit)
        
        string_matrix=sprintf('  Session %2d  ',Index_Selected(1));
            for index=2:Run_limit
                if(Index_Selected(:)>=10)
                    string_matrix=[string_matrix; sprintf('  Session %d  ',Index_Selected(index))];
                else
                    string_matrix=[string_matrix; sprintf('  Session %2d  ',Index_Selected(index))];
                end
            end
        legend(string_matrix,-1);
        


% --------------------------------------------------------------------
function menu_help_Callback(hObject, eventdata, handles)
% hObject    handle to menu_help (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function menu_pronytool_Callback(hObject, eventdata, handles)
% hObject    handle to menu_pronytool (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
HelpPath = which ('pronytoolhelp.html');
web(HelpPath,'-browser');

% --------------------------------------------------------------------
function menu_about_Callback(hObject, eventdata, handles)
% hObject    handle to menu_about (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
HelpPath = which ('about.html');
web(HelpPath,'-browser'); 


% --------------------------------------------------------------------
function menu_demos_Callback(hObject, eventdata, handles)
% hObject    handle to menu_demos (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

HelpPath = which ('demos.html');
web(HelpPath,'-browser');


% --------------------------------------------------------------------
function menu_gridoff_Callback(hObject, eventdata, handles)
% hObject    handle to menu_gridoff (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


axes(handles.axes_pole);
grid off;

% --------------------------------------------------------------------
function menu_gridon_Callback(hObject, eventdata, handles)
% hObject    handle to menu_gridoff (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


axes(handles.axes_pole);
grid on;


% --------------------------------------------------------------------
function plotnew_poles_Callback(hObject, eventdata, handles)
% hObject    handle to plotnew_poles (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
        % Get the column size of Index_Selected
        [IIIGuiData,Index_Selected,max_modes]=export_compare_data(handles);
        Run_limit=size(Index_Selected,2);
        for index=1:Run_limit
            p=IIIGuiData(index).poles;
            p_size=size(p,1); % Get the column size of p
            diff_size=max_modes-p_size;
            if (p_size<max_modes)
                dummy(1:diff_size,1)=-9;   % Create dummy poles of -9
                dummy_rowsize=size(dummy,1);
                if(dummy_rowsize>diff_size)
                    dummy_new=dummy(1:diff_size);
                else
                    dummy_new=dummy(1:diff_size);
                end
                p1=vertcat(p,dummy_new);
            else
                p1=p;
            end
            idennz_mat(:,index)=p1;
        end
        figure('Color','White'),zplane(-9,idennz_mat,{'w^','x'});  % dummy zero at -9
        axis([-1.1 1.1 -1.1 1.1]);xlabel('Real Part'), ylabel('Imaginary Part');
        title('Poles Plot');
        legend_poles(handles,Index_Selected,Run_limit);
        
% --------------------------------------------------------------------
function plotnew_seerror_Callback(hObject, eventdata, handles)
% hObject    handle to plotnew_seerror (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
        [IIIGuiData,Index_Selected,max_modes]=export_compare_data(handles);
        Run_limit=size(Index_Selected,2);
        S=['m:';'b-';'k:';'r-';'g:'];
        row_S=size(S,1);
        figure('Color','White');
        for index=1:Run_limit
            colorindex=mod(index,row_S);% limit colorindex to the row size of S
            % avoid zero value of colorindex, it will happen when row_
            if (colorindex==0)
                colorindex=row_S;
            end
            plot(IIIGuiData(index).x_data,IIIGuiData(index).seerror,S(colorindex));
            hold on;
        end
         xlabel('Time'), ylabel('Squared Error')
         title('Squared Error Plot');
         legend_seerror(handles,Index_Selected,Run_limit);
         hold off;

% --------------------------------------------------------------------
function plotnew_res_Callback(hObject, eventdata, handles)
% hObject    handle to plotnew_res (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
         [IIIGuiData,Index_Selected,max_modes]=export_compare_data(handles);
         Run_limit=size(Index_Selected,2);
         S=['m:';'b-';'k:';'r-';'g:'];
         row_S=size(S,1);
         figure('Color','White');
         for index=1:Run_limit
            colorindex=mod(index,row_S);% limit colorindex to the row size of S
            % avoid zero value of colorindex, it will happen when row_
            if (colorindex==0)
                colorindex=row_S;
            end
            new_index=1:IIIGuiData(index).SUB_N;
            aa_list=IIIGuiData(index).residues;
            semilogy(new_index,aa_list,S(colorindex))
            if(Run_limit==1)
                axis([0 max(new_index)+1 0 1.1*max(aa_list)]);
            end
            hold on;
        end
        xlabel('Index'), ylabel('Residue Magnitude')
        title('Prony Residue Magnitude "Decay"')
        legend_seerror(handles,Index_Selected,Run_limit);
        hold off;

% --------------------------------------------------------------------
function plotnew_energy_Callback(hObject, eventdata, handles)
% hObject    handle to plotnew_energy (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
         [IIIGuiData,Index_Selected,max_modes]=export_compare_data(handles); 
         Run_limit=size(Index_Selected,2);
         S=['m:';'b-';'k:';'r-';'g:'];
         row_S=size(S,1);
         figure('Color','White');
         for index=1:Run_limit
            colorindex=mod(index,row_S);% limit colorindex to the row size of S
            % avoid zero value of colorindex, it will happen when row_
            if (colorindex==0)
                colorindex=row_S;
            end
            new_index=1:IIIGuiData(index).SUB_N;
            energy=IIIGuiData(index).energy;
            energy_size=size(energy,2);
            semilogy(new_index,energy,S(colorindex));
            axis([0 energy_size+1 0 1.1*max(energy)]);
            hold on;
        end
        xlabel('Index'),ylabel('Energy')
        title('Energy of Prony Modes');
        legend_seerror(handles,Index_Selected,Run_limit);
        hold off;

% --------------------------------------------------------------------
function Cmenu_plots_Callback(hObject, eventdata, handles)
% hObject    handle to Cmenu_plots (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Plot_new_Callback(hObject, eventdata, handles)
% hObject    handle to Plot_new (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

function [IIIGuiData,Index_Selected,max_modes]=export_compare_data(handles)
    
    IIIGuiData = struct('runname',[],...
        'poles',[],'residues',[],...
        'energy',[],'seerror',[],'x_data',[],'SUB_N',[]);
    ResultNum = 1;
    % save export data
   if(handles.flag_menuopen==1)
        SaveData=evalin('base','CmpData.SaveData');
    else
        SaveData=evalin('base','SaveData');
    end
    Index_Selected=get(handles.lstbx_session,'Value');
    % Get the column size of Index_Selected
    Run_limit=size(Index_Selected,2);
    % if nothing is selected
    if (isempty(Index_Selected))
        errordlg('Please Select the Sessions to be Compared','No Session Selected !!');
        whitebg('k'); 
    end
    
        for index=1:Run_limit
            Run=Index_Selected(index);
            mode_sizes(index)=SaveData(Run).modes;
        end
         
         max_modes=max(mode_sizes);
         for index=1:Run_limit
             Run=Index_Selected(index);
            [dp_x,dp_y,ai,a_list,SUB_IND,p,energy]= preparecomparedata(SaveData,Run);
            seerror=(dp_y(:)-ai(:)).^2;
            IIIGuiData(index).runname=['Session ',num2str(Run)];
            IIIGuiData(index).seerror=seerror;
            IIIGuiData(index).x_data=dp_x;
            [inummz,idennz]=residuez(a_list(SUB_IND),p(SUB_IND),1);
            [z,p,k] = tf2zp(inummz,idennz);
            IIIGuiData(index).poles=p;
            aa_list=abs(2*a_list(SUB_IND'));
            IIIGuiData(index).SUB_N=size(SUB_IND,2);
            IIIGuiData(index).residues=aa_list;
            IIIGuiData(index).energy=energy;
        end
        
  


% --------------------------------------------------------------------
function menu_export_Callback(hObject, eventdata, handles)
% hObject    handle to menu_export (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[IIIGuiData,Index_Selected,max_modes]=export_compare_data(handles);
assignin('base','IIIGuiData',IIIGuiData);
exportresults;


% --------------------------------------------------------------------
function menu_data_Callback(hObject, eventdata, handles)
% hObject    handle to menu_tools (see GCBO)  
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


⌨️ 快捷键说明

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