comparison m-toolbox/classes/@ssm/reshuffleSym.m @ 0:f0afece42f48

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