@@ -486,6 +486,16 @@ function PlotLoopGain_checkbox_Callback(hObject, eventdata, handles)
486486
487487 BodePlot(handles , false , false )
488488
489+ function PlotGMPM_checkbox_Callback(hObject , eventdata , handles )
490+ [AllDisabled , ~ ] = CheckStateCheckboxes(handles );
491+ if AllDisabled
492+ EnableDisableButtons(handles , ' off' )
493+ else
494+ EnableDisableButtons(handles , ' on' )
495+ end
496+
497+ BodePlot(handles , false , false )
498+
489499%% --- Executes on button presses
490500function UndockBode_pushbutton_Callback(hObject , eventdata , handles )
491501 BodePlot(handles , true , false )
@@ -550,36 +560,44 @@ function BodePlot(handles, undock, exportData)
550560 end
551561
552562 if get(handles .PlotLoopGain_checkbox ,' value' )
553- legendMargins = cell(length(handles .SelectedListboxContents ), 6 );
554- legendMargins(: ,1 ) = {' GM: ' };
555- legendMargins(: ,3 ) = {' [dB] ' };
556- legendMargins(: ,4 ) = {' PM: ' };
557- legendMargins(: ,6 ) = {' [deg] ' };
563+ if get(handles .PlotGMPM_checkbox ,' value' )
564+ legendMargins = cell(length(handles .SelectedListboxContents ), 6 );
565+ legendMargins(: ,1 ) = {' GM: ' };
566+ legendMargins(: ,3 ) = {' [dB] ' };
567+ legendMargins(: ,4 ) = {' PM: ' };
568+ legendMargins(: ,6 ) = {' [deg] ' };
569+ end
558570 if length(handles .SelectedListboxContents ) == 1
559571 S = allmargin(LoopGainMagResponseAbs ,LoopGainPhaseResponse ,w ' );
560572 GM = S .GainMargin(1 );
561573 PM = S .PhaseMargin(1 );
562574 GMFreq = S .GMFrequency(1 );
563575 PMFreq = S .PMFrequency(1 );
564576
565- legendMargins{2 } = num2str(mag2db(GM ));
566- legendMargins{5 } = num2str(PM );
567- legendMargins = strcat(legendMargins{1 }, legendMargins{2 }, ...
568- legendMargins{3 }, legendMargins{4 }, legendMargins{5 }, ...
569- legendMargins{6 });
577+ if get(handles .PlotGMPM_checkbox ,' value' )
578+ legendMargins{2 } = num2str(mag2db(GM ));
579+ legendMargins{5 } = num2str(PM );
580+ legendMargins = strcat(legendMargins{1 }, legendMargins{2 }, ...
581+ legendMargins{3 }, legendMargins{4 }, legendMargins{5 }, ...
582+ legendMargins{6 });
583+ end
570584 else
571585 for i = 1 : length(handles .SelectedListboxContents )
572586 S(i ) = allmargin(LoopGainMagResponseAbs(: ,i ),LoopGainPhaseResponse(: ,i ),w ' );
573587 GM(i ) = S(i ).GainMargin(1 );
574588 PM(i ) = S(i ).PhaseMargin(1 );
575589 GMFreq(i ) = S(i ).GMFrequency(1 );
576590 PMFreq(i ) = S(i ).PMFrequency(1 );
577- legendMargins{i ,2 } = num2str(mag2db(GM(i )));
578- legendMargins{i ,5 } = num2str(PM(i ));
591+ if get(handles .PlotGMPM_checkbox ,' value' )
592+ legendMargins{i ,2 } = num2str(mag2db(GM(i )));
593+ legendMargins{i ,5 } = num2str(PM(i ));
594+ end
595+ end
596+ if get(handles .PlotGMPM_checkbox ,' value' )
597+ legendMargins = strcat(legendMargins(: ,1 ), legendMargins(: ,2 ), ...
598+ legendMargins(: ,3 ), legendMargins(: ,4 ), legendMargins(: ,5 ), ...
599+ legendMargins(: ,6 ));
579600 end
580- legendMargins = strcat(legendMargins(: ,1 ), legendMargins(: ,2 ), ...
581- legendMargins(: ,3 ), legendMargins(: ,4 ), legendMargins(: ,5 ), ...
582- legendMargins(: ,6 ));
583601 end
584602 end
585603
@@ -590,7 +608,7 @@ function BodePlot(handles, undock, exportData)
590608
591609 PitchAngles = str2double(handles .SelectedListboxContents );
592610
593- uisave({' frd_Plant' , ' frd_Controller' , ' frd_LoopGain' , ' PitchAngles' }, ' ExportPlotData' )
611+ uisave({' frd_Plant' , ' frd_Controller' , ' frd_LoopGain' , ' PitchAngles' , ' GM ' , ' PM ' , ' GMFreq ' , ' PMFreq ' }, ' ExportPlotData' )
594612 end
595613
596614 if undock
@@ -611,10 +629,13 @@ function BodePlot(handles, undock, exportData)
611629 hold on
612630 end
613631 if get(handles .PlotLoopGain_checkbox , ' Value' )
632+ if get(handles .PlotGMPM_checkbox ,' value' )
633+ h(i ) = semilogx([GMFreq(i ) GMFreq(i )], [0 - mag2db(GM(i ))], ' Color' , [0 0.8 0 ], ' LineStyle' , plotLineStyle{2 }, ' LineWidth' , plotLineWidth(1 ));
634+ h(i ) = semilogx(GMFreq(i ), - mag2db(GM(i )), ' o' , ' Color' , [0 0.8 0 ], ' LineStyle' , plotLineStyle{1 }, ' LineWidth' , plotLineWidth(1 ));
635+
636+ end
614637 h(i ) = semilogx(w , LoopGainMagResponse(: ,i ), ' Color' , ones(1 ,3 )*plotCol(i ), ' LineStyle' , plotLineStyle{3 }, ' LineWidth' , plotLineWidth(3 ));
615638 hold on
616- h(i ) = semilogx([GMFreq(i ) GMFreq(i )], [0 - mag2db(GM(i ))], ' Color' , [0 0.8 0 ], ' LineStyle' , plotLineStyle{2 }, ' LineWidth' , plotLineWidth(1 ));
617- h(i ) = semilogx(GMFreq(i ), - mag2db(GM(i )), ' o' , ' Color' , [0 0.8 0 ], ' LineStyle' , plotLineStyle{1 }, ' LineWidth' , plotLineWidth(1 ));
618639 end
619640 end
620641 semilogx(w , zeros(1 ,length(w )), ' LineStyle' , ' --' , ' Color' , ' k' , ' LineWidth' , 0.5 )
@@ -624,7 +645,9 @@ function BodePlot(handles, undock, exportData)
624645 grid on
625646
626647 legendEntry = handles .SelectedListboxContents ;
627- legendEntry = strcat(legendEntry ,legendMargins );
648+ if get(handles .PlotGMPM_checkbox ,' value' ) && exist(' legendMargins' ,' var' )
649+ legendEntry = strcat(legendEntry ,legendMargins );
650+ end
628651 if exist(' h' , ' var' )
629652 legend(h , legendEntry , ' Location' , ' SouthWest' )
630653 end
@@ -652,8 +675,10 @@ function BodePlot(handles, undock, exportData)
652675 dotPM = 180 + PM(i );
653676 end
654677 linePM = [-180 dotPM ];
655- h(i ) = semilogx([PMFreq(i ) PMFreq(i )], linePM , ' Color' , [0 0.8 0 ], ' LineStyle' , plotLineStyle{2 }, ' LineWidth' , plotLineWidth(1 ));
656- h(i ) = semilogx(PMFreq(i ), dotPM , ' o' , ' Color' , [0 0.8 0 ], ' LineStyle' , plotLineStyle{1 }, ' LineWidth' , plotLineWidth(1 ));
678+ if get(handles .PlotGMPM_checkbox ,' value' )
679+ h(i ) = semilogx([PMFreq(i ) PMFreq(i )], linePM , ' Color' , [0 0.8 0 ], ' LineStyle' , plotLineStyle{2 }, ' LineWidth' , plotLineWidth(1 ));
680+ h(i ) = semilogx(PMFreq(i ), dotPM , ' o' , ' Color' , [0 0.8 0 ], ' LineStyle' , plotLineStyle{1 }, ' LineWidth' , plotLineWidth(1 ));
681+ end
657682 end
658683 end
659684 semilogx(w , 180 * ones(1 ,length(w )), w , - 180 * ones(1 ,length(w )), ' LineStyle' , ' --' , ' Color' , ' k' , ' LineWidth' , 0.5 )
@@ -828,6 +853,7 @@ function EnableDisableCheckBoxes(handles, state)
828853 set(handles .PlotNotch_checkbox , ' Enable' , state )
829854 set(handles .PlotNom_checkbox , ' Enable' , state )
830855 set(handles .PlotLoopGain_checkbox , ' Enable' , state )
856+ set(handles .PlotGMPM_checkbox , ' Enable' , state )
831857
832858function EnableDisableButtons(handles , state )
833859 set(handles .UndockBode_pushbutton , ' Enable' , state )
@@ -840,8 +866,9 @@ function EnableDisableButtons(handles, state)
840866 checkBox(3 ) = get(handles .PlotNotch_checkbox , ' Value' );
841867 checkBox(4 ) = get(handles .PlotNom_checkbox , ' Value' );
842868 checkBox(5 ) = get(handles .PlotLoopGain_checkbox , ' Value' );
869+ checkBox(6 ) = get(handles .PlotGMPM_checkbox , ' Value' );
843870
844- AllDisabled = all(checkBox(1 : 5 ) == 0 );
871+ AllDisabled = all(checkBox(1 : 6 ) == 0 );
845872 AllControllersEnabled = all(checkBox(1 : 3 ) == 1 );
846873
847874function Controller = calculateController(handles , LoopGainCheckbox )
0 commit comments