0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % RESHUFFLE rearragnes a ssm object using the given inputs and outputs.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % DESCRIPTION: rearranges a ssm object using the given inputs and outputs.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % CALL: sys = reshuffle(sys, inputs1, inputs2, inputs3, states,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % outputs, outputStates)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % INPUTS:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % 'sys' - ssm object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % 'inputs1' - these will constitute the input block 1 of the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % ssm (order is user defined)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % 'inputs2' - these will constitute the input block 1 of the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % ssm (order is user defined)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % 'inputs3' - these will constitute the input block 1 of the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % ssm (order is user defined)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % 'states' - states to keep (order is user defined)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % 'outputs' - outputs to keep, first output block (order is user
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % defined)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % 'outputStates' - states to return as an output, second output block
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % (order is user defined)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % The inputs/states/outputs can only be indexed using a cellstr containing
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % block names or port names.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % OUTPUTS:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 % 'sys' - a ssm object.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % VERSION :
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 % $Id: reshuffle.m,v 1.7 2011/04/08 08:56:23 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 function sys = reshuffle(sys, inputs1, inputs2, inputs3, states, outputs, outputStates)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 [iBlockInputs1 iPortInputs1] = findPortWithMixedNames( sys.inputs, inputs1 );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 [iBlockInputs2 iPortInputs2] = findPortWithMixedNames( sys.inputs, inputs2 );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 [iBlockInputs3 iPortInputs3] = findPortWithMixedNames( sys.inputs, inputs3 );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 [iBlockStatesOut iPortStatesOut] = findPortWithMixedNames( sys.states, outputStates );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 [iBlockStates iPortStates] = findPortWithMixedNames( sys.states, states );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 [iBlockOutputsOut iPortOutputsOut] = findPortWithMixedNames( sys.outputs, outputs );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 inputs1 = mergeBlocksWithPositionIndex(sys.inputs, iBlockInputs1, iPortInputs1, 'inputs1');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 inputs2 = mergeBlocksWithPositionIndex(sys.inputs, iBlockInputs2, iPortInputs2, 'inputs2');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 inputs3 = mergeBlocksWithPositionIndex(sys.inputs, iBlockInputs3, iPortInputs3, 'inputs3');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 States = mergeBlocksWithPositionIndex(sys.states, iBlockStates, iPortStates, 'states');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 StatesOut = mergeBlocksWithPositionIndex(sys.states, iBlockStatesOut, iPortStatesOut, 'statesOut');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 OutputsOut = mergeBlocksWithPositionIndex(sys.outputs, iBlockOutputsOut, iPortOutputsOut, 'outputsOut');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 % cell_mat lines wanted cols wanted
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 A = ssm.blockMatIndex(sys.amats, iBlockStates , iPortStates , iBlockStates , iPortStates );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 C = ssm.blockMatIndex(sys.cmats, iBlockOutputsOut, iPortOutputsOut, iBlockStates , iPortStates );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 B = ssm.blockMatIndex(sys.bmats, iBlockStates , iPortStates , iBlockInputs1, iPortInputs1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 D = ssm.blockMatIndex(sys.dmats, iBlockOutputsOut, iPortOutputsOut, iBlockInputs1, iPortInputs1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 E = ssm.blockMatIndex(sys.bmats, iBlockStates , iPortStates , iBlockInputs2, iPortInputs2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 F = ssm.blockMatIndex(sys.dmats, iBlockOutputsOut, iPortOutputsOut, iBlockInputs2, iPortInputs2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 G = ssm.blockMatIndex(sys.bmats, iBlockStates , iPortStates , iBlockInputs3, iPortInputs3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 H = ssm.blockMatIndex(sys.dmats, iBlockOutputsOut, iPortOutputsOut, iBlockInputs3, iPortInputs3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 Y = eye(sum(sys.statesizes));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 Y = ssm.blockMatRecut(Y, sys.statesizes, sys.statesizes);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 Cstates = ssm.blockMatIndex( Y, iBlockStatesOut, iPortStatesOut, iBlockStates , iPortStates );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 sys.amats = {A};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 sys.bmats = {B E G };
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 sys.cmats = {Cstates; C};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 sys.dmats = {[] zeros(size(Cstates,1),size(F,2)) zeros(size(Cstates,1), size(H,2)) ;...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 D F H };
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 sys.inputs = [inputs1 inputs2 inputs3];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 sys.states = States ;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 sys.outputs = [StatesOut OutputsOut];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 end
|