diff m-toolbox/html_help/help/ug/ssm_modify_content.html @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/html_help/help/ug/ssm_modify_content.html	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,316 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+	<TITLE></TITLE>
+	<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.1  (Win32)">
+	<META NAME="CREATED" CONTENT="0;0">
+	<META NAME="CHANGEDBY" CONTENT="Adrien G">
+	<META NAME="CHANGED" CONTENT="20090828;15564200">
+</HEAD>
+<BODY LANG="en-US" DIR="LTR">
+<P>Built-in models enable to build fast predefined models to use
+later in simulations. 
+</P>
+<H2>Modifying using the setter functions</H2>
+<P><FONT COLOR="#000000">It is possible to set the content of the
+fields &ldquo;input&rdquo;, &ldquo;output&rdquo;, &ldquo;states&rdquo;,
+as well as the field &ldquo;params&rdquo;.</FONT></P>
+<P><FONT COLOR="#000000">Here is a simple model</FONT></P>
+<DIV CLASS="fragment"><PRE><FONT COLOR="#000000">&gt;&gt; name = </FONT><FONT COLOR="#a020f0">'sys'</FONT><FONT COLOR="#000000">;</FONT>
+&gt;&gt; timestep = 0;
+&gt;&gt; amats = cell(3,3);
+&gt;&gt; bmats = cell(3,3);
+&gt;&gt; cmats = cell(3,3);
+&gt;&gt; dmats = cell(3,3);
+<FONT COLOR="#000000">&gt;&gt; amats{1,1} = -(sym(</FONT><FONT COLOR="#a020f0">'OMEGA'</FONT><FONT COLOR="#000000">));</FONT>
+&gt;&gt; amats{2,2} = -2;
+&gt;&gt; amats{3,3} = [0 1 ; -0.05 -0.01];
+&gt;&gt; amats{3,1} = [-1;-3];
+&gt;&gt; bmats{1,1} = 1;
+&gt;&gt; bmats{2,2} = 2;
+&gt;&gt; bmats{3,3} = 3*eye(2);
+&gt;&gt; cmats{1,1} = 1;
+&gt;&gt; cmats{2,2} = 1;
+&gt;&gt; cmats{3,3} = eye(2);
+&gt;&gt; dmats{1,3} = [6 6];
+&gt;&gt; dmats{2,1} = 6;
+&gt;&gt; dmats{3,2} = [6;6];
+<FONT COLOR="#000000">&gt;&gt; sys = ssm(plist( </FONT><FONT COLOR="#0000ff">...</FONT>
+<FONT COLOR="#a020f0">'amats'</FONT><FONT COLOR="#000000">,amats, </FONT><FONT COLOR="#a020f0">'bmats'</FONT><FONT COLOR="#000000">,bmats, </FONT><FONT COLOR="#a020f0">'cmats'</FONT><FONT COLOR="#000000">,cmats, </FONT><FONT COLOR="#a020f0">'dmats'</FONT><FONT COLOR="#000000">,dmats, </FONT><FONT COLOR="#0000ff">...</FONT>
+<FONT COLOR="#a020f0">'timestep'</FONT><FONT COLOR="#000000">,timestep, </FONT><FONT COLOR="#a020f0">'name'</FONT><FONT COLOR="#000000">,name));</FONT>
+<FONT COLOR="#000000">&gt;&gt; sys.setParams(plist({</FONT><FONT COLOR="#a020f0">'OMEGA'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'system frequency'</FONT><FONT COLOR="#000000">}, 2))</FONT>
+<FONT SIZE=2><FONT FACE="Courier New, monospace"><FONT COLOR="#000000">M: running ssm/ssm</FONT></FONT></FONT>
+M: running ssmFromDescription
+M: running validate
+M: running ssm/setParams
+M: running display
+------ ssm/1 -------
+amats: { [1x1] [] [] 
+[] [1x1] [] 
+[2x1] [] [2x2] } [3x3]
+mmats: { [1x1] [] [] 
+[] [1x1] [] 
+[] [] [2x2] } [3x3]
+bmats: { [1x1] [] [] 
+[] [1x1] [] 
+[] [] [2x2] } [3x3]
+cmats: { [1x1] [] [] 
+[] [1x1] [] 
+[] [] [2x2] } [3x3]
+dmats: { [] [] [1x2] 
+[1x1] [] [] 
+[] [2x1] [] } [3x3]
+timestep: 0
+inputs: [1x3 ssmblock]
+1 : input 1 | input 1 &gt; 1 []
+2 : input 2 | input 2 &gt; 1 []
+3 : input 3 | input 3 &gt; 1 [], input 3 &gt; 2 []
+states: [1x3 ssmblock]
+1 : state 1 | state 1 &gt; 1 []
+2 : state 2 | state 2 &gt; 1 []
+3 : state 3 | state 3 &gt; 1 [], state 3 &gt; 2 []
+outputs: [1x3 ssmblock]
+1 : output 1 | output 1 &gt; 1 []
+2 : output 2 | output 2 &gt; 1 []
+3 : output 3 | output 3 &gt; 1 [], output 3 &gt; 2 []
+params: (OMEGA=2) [1x1 plist]
+version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $
+Ninputs: 3
+inputsizes: [1 1 2]
+Noutputs: 3
+outputsizes: [1 1 2]
+Nstates: 3
+statesizes: [1 1 2]
+Nparams: 1
+isnumerical: false
+hist: ssm.hist [1x1 history]
+procinfo: (empty-plist) [1x1 plist]
+plotinfo: (empty-plist) [1x1 plist]
+name: sys
+description: 
+mdlfile: 
+UUID: 227fd0a2-1de0-4e01-855f-d0548e1eb1ff
+--------------------</PRE></DIV><P>
+<BR><BR>
+</P>
+<P>In then we set the names and descriptions of the input blocks, the
+names, descriptions and units of the port variables:</P>
+<DIV CLASS="fragment"><PRE><FONT COLOR="#000000">&gt;&gt; sys.setBlockNames(plist(</FONT><FONT COLOR="#a020f0">'field'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'inputs'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'blocks'</FONT><FONT COLOR="#000000">, [1 2 3], </FONT><FONT COLOR="#a020f0">'names'</FONT><FONT COLOR="#000000">, {</FONT><FONT COLOR="#a020f0">'myinput1'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#a020f0">'myinput2'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#a020f0">'myinput3'</FONT><FONT COLOR="#000000">} ));</FONT>
+<FONT COLOR="#000000">&gt;&gt; sys.setBlockDescriptions(plist(</FONT><FONT COLOR="#a020f0">'field'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'inputs'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'blocks'</FONT><FONT COLOR="#000000">, {</FONT><FONT COLOR="#a020f0">'myinput1'</FONT><FONT COLOR="#000000">}, </FONT><FONT COLOR="#a020f0">'descriptions'</FONT><FONT COLOR="#000000">,{</FONT><FONT COLOR="#a020f0">'myinput1 description'</FONT><FONT COLOR="#000000">} ));</FONT>
+<FONT COLOR="#000000">&gt;&gt; sys.setPortNames(plist(</FONT><FONT COLOR="#a020f0">'field'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'inputs'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'block'</FONT><FONT COLOR="#000000">, {</FONT><FONT COLOR="#a020f0">'myinput3'</FONT><FONT COLOR="#000000">}, </FONT><FONT COLOR="#a020f0">'ports'</FONT><FONT COLOR="#000000">, [1 2], </FONT><FONT COLOR="#a020f0">'names'</FONT><FONT COLOR="#000000">,{</FONT><FONT COLOR="#a020f0">'my port 3-1'</FONT><FONT COLOR="#000000"> </FONT><FONT COLOR="#a020f0">'my port 3-2'</FONT><FONT COLOR="#000000">} ));</FONT>
+<FONT COLOR="#000000">&gt;&gt; sys.setPortDescriptions(plist(</FONT><FONT COLOR="#a020f0">'field'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'inputs'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'block'</FONT><FONT COLOR="#000000">, {</FONT><FONT COLOR="#a020f0">'myinput3'</FONT><FONT COLOR="#000000">}, </FONT><FONT COLOR="#a020f0">'ports'</FONT><FONT COLOR="#000000">, [1 2], </FONT><FONT COLOR="#a020f0">'descriptions'</FONT><FONT COLOR="#000000">,{</FONT><FONT COLOR="#a020f0">'first description'</FONT><FONT COLOR="#000000"> </FONT><FONT COLOR="#a020f0">'second description'</FONT><FONT COLOR="#000000">} ));</FONT>
+<FONT COLOR="#000000">&gt;&gt; sys.setPortUnits(plist(</FONT><FONT COLOR="#a020f0">'field'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'inputs'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'block'</FONT><FONT COLOR="#000000">, {</FONT><FONT COLOR="#a020f0">'myinput3'</FONT><FONT COLOR="#000000">}, </FONT><FONT COLOR="#a020f0">'ports'</FONT><FONT COLOR="#000000">, [1 2], </FONT><FONT COLOR="#a020f0">'units'</FONT><FONT COLOR="#000000">, [unit(</FONT><FONT COLOR="#a020f0">'kg m^-2'</FONT><FONT COLOR="#000000">) unit(</FONT><FONT COLOR="#a020f0">'m'</FONT><FONT COLOR="#000000">)] ));</FONT>
+&gt;&gt; sys.inputs
+M: running ssm/setBlockNames
+M: running ssm/setBlockDescriptions
+M: running ssm/setPortNames
+------ ssmport/1 -------
+name: my port 3-1
+units: [] [1x1 unit]
+description: 
+version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $
+------------------------
+------ ssmport/2 -------
+name: my port 3-2
+units: [] [1x1 unit]
+description: 
+version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $
+------------------------
+M: running ssm/setPortDescriptions
+------ ssmport/1 -------
+name: my port 3-1
+units: [] [1x1 unit]
+description: first description
+version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $
+------------------------
+------ ssmport/2 -------
+name: my port 3-2
+units: [] [1x1 unit]
+description: second description
+version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $
+------------------------
+M: running ssm/setPortUnits
+------ ssmblock/1 -------
+name: myinput1
+ports: input 1 &gt; 1 [] [1x1 ssmport]
+description: myinput1 description
+version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $
+-------------------------
+------ ssmblock/2 -------
+name: myinput2
+ports: input 2 &gt; 1 [] [1x1 ssmport]
+description: 
+version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $
+-------------------------
+------ ssmblock/3 -------
+name: myinput3
+ports: my port 3-1 [kg m^(-2)], my port 3-2 [m] [1x2 ssmport]
+description: 
+version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $
+<FONT SIZE=2><FONT FACE="Courier New, monospace"><FONT COLOR="#000000">-------------------------</FONT></FONT></FONT></PRE></DIV><H2>
+Modifying the parameter values</H2>
+<P>Once the parameter field &ldquo;params&rdquo; is set, one may want
+to set or modify (like in an optimizer) the parameter values. This is
+done by the functions &ldquo;*Parameters.m&rdquo;. The function
+setParameters takes two inputs ('setnames' and 'setvalues') which are
+the names of the parameters to modify and the values assigned to
+them.</P>
+<DIV CLASS="fragment"><PRE>&gt;&gt; sys.params
+<FONT COLOR="#000000">&gt;&gt; sys.setParameters(</FONT><FONT COLOR="#a020f0">'OMEGA'</FONT><FONT COLOR="#000000">, 0.002);</FONT>
+&gt;&gt; sys.params
+----------- plist 01 -----------
+n params: 1
+---- param 1 ----
+key: OMEGA
+val: 2
+desc: system frequency
+-----------------
+description: 
+UUID: 84ff1ed8-eee2-406c-89d8-7e6e703d36dd
+--------------------------------
+M: running setParameters
+M: running ssm/ssm
+----------- plist 01 -----------
+n params: 1
+---- param 1 ----
+key: OMEGA
+val: 0.002
+desc: system frequency
+-----------------
+description: 
+UUID: 84ff1ed8-eee2-406c-89d8-7e6e703d36dd
+--------------------------------</PRE></DIV><P>
+The function subsParameterskeep and Parameters substitute numerical
+values to the symbolic expressions, using a list of the parameters to
+substitute (or its complementary). All parameters substituted are
+removed from the &ldquo;params&rdquo; field. The call
+&lt;system&gt;.keepParameters substitues all the parameters. The
+field isnumerical is then set to 1, unless a parameter in the
+matrices was forgotten in the params field.</P>
+<DIV CLASS="fragment"><PRE>&gt;&gt; sys.keepParameters;
+&gt;&gt; sys.params
+&gt;&gt; sys.isNumeric
+
+M: running keepParameters
+----------- plist 01 -----------
+n params: 0
+description: 
+UUID: 84ff1ed8-eee2-406c-89d8-7e6e703d36dd
+--------------------------------
+ans =
+1</PRE></DIV><H2>
+Modifying the inputs/states/outputs</H2>
+<P><FONT COLOR="#000000">Les us first build a simple system
+constituted of four parallel 1</FONT><FONT COLOR="#000000"><SUP>st</SUP></FONT><FONT COLOR="#000000">
+order systems.</FONT></P>
+<DIV CLASS="fragment"><PRE><FONT COLOR="#000000">&gt;&gt; name = </FONT><FONT COLOR="#a020f0">'sys'</FONT><FONT COLOR="#000000">;</FONT>
+&gt;&gt; timestep = 0;
+&gt;&gt; amats = {diag([-1 -2 -3 -4])};
+&gt;&gt; bmats = {diag([1 2 0 0])};
+&gt;&gt; cmats = {[diag([1 0 3 0]) ; [0 0 0 0 ]]};
+&gt;&gt; dmats = {[diag([0 0 0 0]) ; [0 0 0 0 ]]};
+<FONT COLOR="#000000">&gt;&gt; sys = ssm(plist( </FONT><FONT COLOR="#0000ff">...</FONT>
+<FONT COLOR="#a020f0">'amats'</FONT><FONT COLOR="#000000">,amats, </FONT><FONT COLOR="#a020f0">'bmats'</FONT><FONT COLOR="#000000">,bmats, </FONT><FONT COLOR="#a020f0">'cmats'</FONT><FONT COLOR="#000000">,cmats, </FONT><FONT COLOR="#a020f0">'dmats'</FONT><FONT COLOR="#000000">,dmats, </FONT><FONT COLOR="#0000ff">...</FONT>
+<FONT COLOR="#a020f0">'timestep'</FONT><FONT COLOR="#000000">,timestep, </FONT><FONT COLOR="#a020f0">'name'</FONT><FONT COLOR="#000000">,name));</FONT>
+<FONT COLOR="#000000">It is possible to obtain the structural realization of the system using sMinReal. This function deletes states which are either not observable or controllable. However, there may still exist such linear combinations of states.</FONT>
+<FONT COLOR="#000000">The process only modify the states, here the 2</FONT><FONT COLOR="#000000"><SUP>nd</SUP></FONT><FONT COLOR="#000000"> and 4rt states disappear since they are not observable, and the 3</FONT><FONT COLOR="#000000"><SUP>rd</SUP></FONT><FONT COLOR="#000000"> and 4</FONT><FONT COLOR="#000000"><SUP>th</SUP></FONT><FONT COLOR="#000000"> disappear since they are not controllable.</FONT>
+&gt;&gt; sys.sMinReal
+M: running ssm/ssm
+M: running ssmFromDescription
+M: running validate
+M: running ssm/sMinReal
+M: running display
+------ ssm/1 -------
+amats: { [1x1] } [1x1]
+mmats: { [1x1] } [1x1]
+bmats: { [1x4] } [1x1]
+cmats: { [5x1] } [1x1]
+dmats: { [] } [1x1]
+timestep: 0
+inputs: [1x1 ssmblock]
+1 : input 1 | input 1 &gt; 1 [], input 1 &gt; 2 [], input 1 &gt; 3 [], input 1 &gt; 4 []
+states: [1x1 ssmblock]
+1 : state 1 | state 1 &gt; 1 []
+outputs: [1x1 ssmblock]
+1 : output 1 | output 1 &gt; 1 [], output 1 &gt; 2 [], output 1 &gt; 3 [], output 1 &gt; 4 [], output 1 &gt; 5 []
+params: (empty-plist) [1x1 plist]
+version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $
+Ninputs: 1
+inputsizes: 4
+Noutputs: 1
+outputsizes: 5
+Nstates: 1
+statesizes: 1
+Nparams: 0
+isnumerical: true
+hist: ssm.hist [1x1 history]
+procinfo: (empty-plist) [1x1 plist]
+plotinfo: (empty-plist) [1x1 plist]
+name: sys
+description: 
+mdlfile: 
+UUID: 349cd9c4-ad91-4151-b542-63d34b01bed8
+--------------------</PRE></DIV><P>
+Then we can work on the input/outputs to simplify the model.</P>
+<P>The user must specify which block variable he want to keep, and
+three syntaxes are allowed. 
+</P>
+<UL>
+	<LI><P>'ALL'
+	meaning all ports in all blocks are kept</P>
+	<LI><P>{&lt;varname1&gt;
+	&lt;varname2&gt; &hellip;} giving the name of each port to keep, in
+	this case one must ensure ports of different blocks have different
+	names.</P>
+	<LI><P>{&lt;logical
+	index for block1&gt; &lt;double index for block2&gt; &lt;varnames
+	cellstr for block3&gt; &ldquo;ALL&rdquo; &ldquo;NONE&rdquo;} using a
+	different index for each individual block.</P>
+</UL>
+<P>This
+syntax is also used for any converter to select the inputs and
+outputs in the ssm.</P>
+<P>It is important to note that this removes lines and columns in the
+system's matrices, but no parameters are removed. So second order
+parameters that should be remove (by setting them to a neutral value)
+must be taken care of separately.</P>
+<DIV CLASS="fragment"><PRE><FONT FACE="Courier New, monospace"><FONT COLOR="#000000">&gt;&gt; sys.simplify(plist(</FONT><FONT COLOR="#a020f0">'inputs'</FONT><FONT COLOR="#000000">, {[1 2]} , </FONT><FONT COLOR="#a020f0">'states'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#a020f0">'ALL'</FONT><FONT COLOR="#000000"> , </FONT><FONT COLOR="#a020f0">'outputs'</FONT><FONT COLOR="#000000">, { </FONT><FONT COLOR="#a020f0">'output 1 &gt; 1'</FONT><FONT COLOR="#000000"> </FONT><FONT COLOR="#a020f0">'output 1 &gt; 4'</FONT><FONT COLOR="#000000">}))</FONT></FONT>
+<FONT FACE="Courier New, monospace"><FONT COLOR="#000000"><FONT SIZE=2>M: running ssm/simplify</FONT></FONT></FONT>
+<FONT FACE="Courier New, monospace">M: running ssm/ssm</FONT>
+<FONT FACE="Courier New, monospace">M: running ssm/simplify</FONT>
+<FONT FACE="Courier New, monospace">M: running display</FONT>
+<FONT FACE="Courier New, monospace">------ ssm/1 -------</FONT>
+<FONT FACE="Courier New, monospace">amats: { [1x1] } [1x1]</FONT>
+<FONT FACE="Courier New, monospace">mmats: { [1x1] } [1x1]</FONT>
+<FONT FACE="Courier New, monospace">bmats: { [1x2] } [1x1]</FONT>
+<FONT FACE="Courier New, monospace">cmats: { [2x1] } [1x1]</FONT>
+<FONT FACE="Courier New, monospace">dmats: { [] } [1x1]</FONT>
+<FONT FACE="Courier New, monospace">timestep: 0</FONT>
+<FONT FACE="Courier New, monospace">inputs: [1x1 ssmblock]</FONT>
+<FONT FACE="Courier New, monospace">1 : input 1 | input 1 &gt; 1 [], input 1 &gt; 2 []</FONT>
+<FONT FACE="Courier New, monospace">states: [1x1 ssmblock]</FONT>
+<FONT FACE="Courier New, monospace">1 : state 1 | state 1 &gt; 1 []</FONT>
+<FONT FACE="Courier New, monospace">outputs: [1x1 ssmblock]</FONT>
+<FONT FACE="Courier New, monospace">1 : output 1 | output 1 &gt; 1 [], output 1 &gt; 4 []</FONT>
+<FONT FACE="Courier New, monospace">params: (empty-plist) [1x1 plist]</FONT>
+<FONT FACE="Courier New, monospace">version: $Id: ssm_modify_content.html,v 1.2 2009/08/28 15:11:53 adrien Exp $</FONT>
+<FONT FACE="Courier New, monospace">Ninputs: 1</FONT>
+<FONT FACE="Courier New, monospace">inputsizes: 2</FONT>
+<FONT FACE="Courier New, monospace">Noutputs: 1</FONT>
+<FONT FACE="Courier New, monospace">outputsizes: 2</FONT>
+<FONT FACE="Courier New, monospace">Nstates: 1</FONT>
+<FONT FACE="Courier New, monospace">statesizes: 1</FONT>
+<FONT FACE="Courier New, monospace">Nparams: 0</FONT>
+<FONT FACE="Courier New, monospace">isnumerical: true</FONT>
+<FONT FACE="Courier New, monospace">hist: ssm.hist [1x1 history]</FONT>
+<FONT FACE="Courier New, monospace">procinfo: (empty-plist) [1x1 plist]</FONT>
+<FONT FACE="Courier New, monospace">plotinfo: (empty-plist) [1x1 plist]</FONT>
+<FONT FACE="Courier New, monospace">name: sys</FONT>
+<FONT FACE="Courier New, monospace">description: </FONT>
+<FONT FACE="Courier New, monospace">mdlfile: </FONT>
+<FONT FACE="Courier New, monospace">UUID: 8e55110a-eb07-44d2-aaee-4f839a5fb155</FONT>
+<FONT FACE="Courier New, monospace">--------------------</FONT>
+</PRE></DIV>
+</BODY>
+</HTML>
\ No newline at end of file