Code covered by the BSD License  

Highlights from
GUI for Routh-Hurwitz Criterion

image thumbnail
from GUI for Routh-Hurwitz Criterion by xianfa zeng
Input commands in the edit text, and it will compute and display the Routh-Hurwitz array.

Routh_Gui()
function Routh_Gui()
% 
% Routh_Gui uses uicontrol to creates the objects on a figure, as
% pushbuttons, edit text.
% You can input the characteristic polynomial in 'edit text' just like that in
% the Matlab Command Window, and after you click 'OK', the programe will
% calculate and disp the Routh-Hurwitz array for the characteristic 
% polynomial. The main compute program is based on the 'routh.m' that
% written by Rivera-Santos, Edmundo J. And it has been changed a little for
% this program.
% 
% note: the input should according to the Matlab rules, and use 'ch' as
% the name for the characteristic polynomial vector.
% 
% for examples:
% (1) For the characteristic polynomial : s^5+s^4+2*s^3+2*s^2+s+1
%  you can input the following command in the editable text fields :
%  ch = [1 1 2 2 1 1];
%  then click button 'OK'.
% 
% (2) For the characteristic polynomial : s^3+a*s^2+b*s+c
%  then you can input the following command in the editable text fields :
%  syms a b c; ch = [1 a b c];
%  then click button 'OK'.
% 
% You can also click 'Demo1' and 'Demo2' buttons to see the examples.
% authorxianfa110
% bloghttp://blog.sina.com.cn/xianfa110
% 
% 
% -- create the figure -- %
Hf = figure('NumberTitle','off',...
    'MenuBar','none',...
    'ReSize','off',...
    'color',[0.8000 0.8000 0.8000],...
    'name','Routh-Hurwitz Criterion');
% 
% -- create a frame -- %
uipanel(Hf,...
    'title','Input',...
    'foregroundcolor',[0.1,0.1,0.8],...
    'fontsize',10,...
    'fontweight','bold',...
    'position',[0.01,0.74,0.97,0.24],...
    'backgroundcolor',[0.8000 0.8000 0.8000]); 
% 
% -- create a pushbutton, call the OnOk function, for computing and results displaying -- %
uicontrol(Hf,...
    'style','pushbutton',...
    'string','OK',...
    'tag','ok',...
    'callback','OnOk',...
    'units','normalized',...
    'position',[0.75,0.77,0.1,0.05])
% 
% -- create a pushbutton, to clear the command in the edit text -- %
uicontrol(Hf,...
    'style','pushbutton',...
    'string','Clear',...
    'callback',['h_input = findobj(gcf,''tag'',''input'');',...
    'set(h_input,''string'','''');h_ok = findobj(gcf,''tag'',''ok'');',...
    'set(h_ok,''enable'',''on'');'],...
    'units','normalized',...
    'position',[0.86,0.77,0.1,0.05])
% 
% -- create a pushbutton, to run Demo1 -- %
uicontrol(Hf,...
    'style','pushbutton',...
    'string','Demo1',...
    'callback',['h_input = findobj(gcf,''tag'',''input'');',...
    'set(h_input,''string'',''ch = [1 1 2 2 1 1];%Demo1'');',...
    'OnOk;'],...
    'tag','demo1',...
    'units','normalized',...
    'position',[0.75,0.86,0.1,0.05])
% 
% -- create a pushbutton, to run Demo2 -- %
uicontrol(Hf,...
    'style','pushbutton',...
    'string','Demo2',...
    'callback',['h_input = findobj(gcf,''tag'',''input'');',...
    'set(h_input,''string'',''syms a b c; ch = [1 a b c];%Demo2'');',...
    'OnOk;'],...
    'tag','demo2',...
    'units','normalized',...
    'position',[0.86,0.86,0.1,0.05])
% 
% -- create a frame -- %
uipanel(Hf,...
    'position',[0.74,0.75,0.23,0.18],...
    'backgroundcolor',[0.8000 0.8000 0.8000]); 
% 
% -- create an edit text, for inputting -- %
uicontrol(Hf,...
    'style','edit',...
    'tag','input',...
    'units','normalized',...
    'position',[0.03,0.75,0.69,0.18],...
    'backgroundcolor','w',...
    'foregroundcolor',[0.1,0.1,0.8],...
    'horizontalalignment','left',...
    'fontsize',10,...
    'fontweight','bold',...
    'string','Use ''ch'' as the name of the characteristic vector!',...
    'max',3);
% 
% -- create a frame -- %
uipanel(Hf,...
    'title','Results',...
    'fontsize',10,...
    'fontweight','bold',...
    'foregroundcolor','r',...
    'position',[0.01,0.08,0.97,0.65],...
    'backgroundcolor',[0.8000 0.8000 0.8000])
% 
% -- create an edit text, for results displaying -- %
uicontrol(Hf,...
    'style','edit',...
    'tag','output',...
    'units','normalized',...
    'position',[0.03,0.1,0.93,0.58],...
    'backgroundcolor','w',...
    'foregroundcolor','r',...
    'horizontalalignment','left',...
    'fontsize',10,...
    'fontweight','bold',...
    'max',3)
% 
% -- close the figure -- %
uicontrol(Hf,...
    'style','pushbutton',...
    'string','close',...
    'callback','delete(gcbf)',...
    'units','normalized',...
    'position',[0.86,0.02,0.1,0.05]);

Contact us at files@mathworks.com