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

📄 sysrepdemo.m

📁 similer program for matlab
💻 M
📖 第 1 页 / 共 2 页
字号:
              disp("coefficients of the numerator and denominator polynomials");              disp(" ")              disp("For example: the transfer function");              disp(" ");              num = [5, -1];              denom = [1, -2, 6];              tfout(num,denom);              disp(" ")              disp("is generated by the following commands:")              cmd = "num = [5, -1]";              run_cmd              cmd = "denom = [1, -2, 6]";              run_cmd              cmd = "sys = tf(num,denom);";              run_cmd              disp("alternatively, the system can be generated in a single command:");              cmd = "sys = tf([5, -1], [1, -2, 6]);";              run_cmd              disp("Notice the output of sys: it is an Octave data structure.")              disp("The details of its member variables are explained under")              disp("System Representation Menu option 5 (the details of system form)")              disp(" ");              disp("The data structure can be observed with the sysout command:")              cmd = "sysout(sys)";              run_cmd              disp("Notice that Octave assigns names to inputs and outputs.")              disp("The user may manually select input and output names; see option 3");              prompt            elseif(tfopt == 2) # discrete time              disp("A transfer function is represented by vectors of the")              disp("coefficients of the numerator and denominator polynomials");              disp("Discrete-time transfer functions require ")              disp("the additional parameter of a sampling period:")              cmd = "sys=tf([5, -1], [1, 2, -6], 1e-3);";              run_cmd              cmd = "sysout(sys)";              run_cmd              disp("The OCST recognizes discrete-time transfer functions and")              disp("accordingly prints them with the frequency domain variable z.");              disp("Notice that Octave assigns names to inputs and outputs.")              disp("The user may set input and output names; see option 3");            elseif(tfopt == 3) # user specified names              disp("The OCST requires all signals to have names.  The OCST assigned default");              disp("names to the signals in the other examples.  We may initialize a transfer");              disp("function with user-specified names as follows: Consider a simple ")              disp("double-integrator model of aircraft roll dynamics with ")              disp("input \"aileron angle\" and output \"theta\".  A ")              disp("system for this model is generated by the command")              cmd = "aircraft=tf(1, [1, 0, 0], 0,\"aileron angle\",\"theta\");";          run_cmd              disp("The sampling  time parameter 0 indicates that the system")              disp("is continuous time.  A positive sampling time indicates a")              disp("discrete-time system (or sampled data system).")              cmd = "sysout(aircraft)";              run_cmd              disp("Notice that the user-selected signal names are listed.")              disp("These signal names are used in OCST plots and design functions.");              disp("(Run the frequency response demo to see an example of the use of ");              disp("signal names in plots.)")              prompt            elseif(tfopt == 4) # help              help  tf              prompt            elseif(tfopt == 6) # return to main menu              formopt = 4;            endif          endwhile        elseif (formopt == 3)          zpopt = 0;          while(zpopt < 5)            zpopt = menu("Zero-pole initialization menu", ...                "Continuous time initialization" , ...                "Discrete time initialization" , ...                "User specified signal names" , ...                "zp details (help zp)", ...                "Return to system initialization menu", ...                "Return to system representation main menu");            if(zpopt == 1) # continuous time              disp("A zero-pole form representation of a system includes vectors")              disp("of the system poles and zeros and a scalar leading coefficient.");              disp(" ")              disp("For example: the transfer function");              disp(" ");              k = 5;              num = [5, -1];              denom = [1, -2, 6];              zpout(num,denom,k);              disp(" ")              disp("is generated by the following commands:")              cmd = "num = [5, -1]";              run_cmd              cmd = "denom = [1, -2, 6]";              run_cmd              cmd = "k = 5";              run_cmd              cmd = "sys = zp(num,denom,k);";              run_cmd              disp("alternatively, the system can be generated in a single command:");              cmd = "sys = zp([5, -1],[1, -2, 6],5);";              run_cmd              disp("Notice the output of sys: it is an Octave data structure.")              disp("The details of its member variables are explained under")              disp("System Representation Menu option 5 (the details of system form)")              disp(" ");              disp("The data structure can be observed with the sysout command:")              cmd = "sysout(sys)";              run_cmd              disp("Notice that Octave assigns names to inputs and outputs.")              disp("The user may manually select input and output names; see option 3");              prompt            elseif(zpopt == 2) # discrete time              disp("A zero-pole form representation of a system includes vectors")              disp("of the system poles and zeros and a scalar leading coefficient.");              disp(" ")              disp("Discrete-time systems require the additional parameter of a sampling period:")              cmd = "sys=zp([5, -1],[1, 2, -6],5,1e-3);";              run_cmd              cmd = "sysout(sys)";              run_cmd              disp("The OCST recognizes discrete-time transfer functions and")              disp("accordingly prints them with the frequency domain variable z.");              disp("Notice that Octave assigns names to inputs and outputs.")              disp("The user may set input and output names; see option 3");            elseif(zpopt == 3) # user specified names              disp("The OCST requires all signals to have names.  The OCST assigned default");              disp("names to the signals in the other examples.  We may initialize a transfer");              disp("function with user-specified names as follows: Consider a simple ")              disp("double-integrator model of aircraft roll dynamics with ")              disp("input \"aileron angle\" and output \"theta\".  A ")              disp("system for this model is generated by the command")              cmd = "aircraft=zp([],[0, 0],1,0,\"aileron angle\",\"theta\");";            run_cmd              disp("The sampling  time parameter 0 indicates that the system")              disp("is continuous time.  A positive sampling time indicates a")              disp("discrete-time system (or sampled data system).")              cmd = "sysout(aircraft)";              run_cmd              disp("Notice that the user-selected signal names are listed.")              disp("These signal names are used in OCST plots and design functions.");              disp("(Run the frequency response demo to see an example of the use of ");              disp("signal names in plots.)")              prompt            elseif(zpopt == 4) # help              help  zp              prompt            elseif(zpopt == 6) # return to main menu              formopt = 4;            endif          endwhile        endif      endwhile    elseif(syschoice == ch_extract)  # extract system information      disp("Extract information from a system data structure in a selected format:")      disp("The actions of operations ss, tf, and zp are reversed by")      disp("respective functions sys2ss, sys2tf, and sys2zp.  The latter two");      disp("functions are applicable only to SISO systems.")      formopt = 0;      while(formopt != 8)        formopt = menu("Extract system information", ...                "in state space form       (sys2ss)", ...                "in transfer function form (sys2tf)", ...                "in zero pole form         (sys2zp)", ...                "signal names       (sysgetsignals,syssetsignals)", ...                "sampling time         (sysgettsam)", ...                "signal dimensions  (sysdimensions)", ...                "primary system type   (sysgettype)", ...                "Return to system representation menu");        if(formopt == 1)          help sys2ss        elseif(formopt == 2)          help sys2tf        elseif(formopt == 3)          help sys2zp        elseif(formopt == 4)          help sysgetsignals          cmd="sys=ss(rand(4),rand(4,2),rand(3,4));";          run_cmd          printf("Example: All signals names can be extracted by\n");          cmd = "[Ast,Ain,Aout,Ayd] = sysgetsignals(sys)";          run_cmd          printf("Example: Input signal names can be extracted as\n");          cmd = "Ain = sysgetsignals(sys,\"in\")";          run_cmd          printf("Example: The name of output signal 2 can be extracted as\n");          cmd = "Aout = sysgetsignals(sys,\"out\",2)";          run_cmd          printf("\nNotice that Aout is returned as a cell array; the signal name\n");          printf("itself is obtained by specifying the input parameter strflg\n");          cmd = "Aout = sysgetsignals(sys,\"out\",2,1)";          run_cmd          prompt          cmd = "help syssetsignals";          run_cmd          printf("Example: set input 2 name to \"motor voltage\"\n");          cmd = "sys = syssetsignals(sys,\"in\",\"motor voltage\",2); sysout(sys)";          run_cmd          printf("Other syssetsignals demos are in the Block diagram demo program bddemo\n");        elseif(formopt == 5)          help sysgettsam        elseif(formopt == 6)          help sysdimensions        elseif(formopt == 7)          help sysgettype        endif        prompt      endwhile    elseif(syschoice== ch_update)      disp("The OCST system data structure format will store a system in the same format")      disp("as that with which it was initialized.  For example, consider the following:")      cmd = "sys=zp([1, 2],[3, 4, 5],6)";      run_cmd      disp(" ")      disp("Notice the internal variables in the structure include zer, pol, and k,")      disp("the required variables for zero-pole form.  We can update the system")      disp("to include state-space form as follows:")      cmd = "sys = sysupdate(sys,\"ss\")";      run_cmd      disp(" ")      disp("Now the sys data structure includes variables a, b, c, and d, as well")      disp("the default state names stname.  sysupdate is usually used internally in")      disp("the OCST, but can be used manually if desired.  A full description of")      disp("sysupdate is as follows:")      help sysupdate      prompt    elseif(syschoice == ch_view)      disp("The sysout command can be used to view a system in any desired format.")      disp("For example, consider the system created as follows:")      cmd = "aircraft=zp(1,[0, 0],1,0,\"aileron angle\",\"theta\");";             run_cmd      disp("The system may be viewed in its default format (zero-pole) as follows")      cmd = "sysout(aircraft)";      run_cmd      disp(" ")      disp("The system may be viewed in state-space or transfer function form as well:")      cmd = "sysout(aircraft,\"ss\")";      run_cmd      cmd = "sysout(aircraft,\"tf\")";      run_cmd      disp("A complete description of sysout is below:")      help sysout      prompt    elseif(syschoice == ch_details)      packedform    endif  endwhile  page_screen_output (save_val);endfunction

⌨️ 快捷键说明

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