Commit 69c55e12 authored by Jakob Gabriel's avatar Jakob Gabriel
Browse files

revised misc.getMinimalInternalModel, lead to minor changes in misc.ss.odes

parent f047e026
......@@ -206,6 +206,16 @@ classdef Odes < handle & matlab.mixin.Copyable
end
end % isequal()
function B = BofInputName(obj, inputName)
arguments
obj misc.ss.Odes;
inputName (1, 1) string;
end
InputNames = misc.ss.removeEnumeration(obj.InputName);
B = obj.odes.B;
B = B(:, strcmp(InputNames, inputName));
end % BofInputName
function [ic, stateName] = getInitialCondition(obj, varargin)
% getInitialCondition reads varargin if there are initial conditions
% defined as name-value-pair with the name according to obj.stateName and
......@@ -370,8 +380,9 @@ classdef Odes < handle & matlab.mixin.Copyable
end
% change C and D in mySs
mySs = set(mySs, 'C', eye(size(mySs.A)), 'D', zeros(size(mySs.A, 1), size(mySs.B, 2)));
mySs = misc.ss.setSignalName(mySs, 'output', {type}, size(mySs.A, 1));
mySs = ss(mySs.A, mySs.B, eye(size(mySs.A)), zeros(size(mySs.A, 1), size(mySs.B, 2)), ...
mySs.Ts, "InputName", mySs.InputName, ...
"OutputName", type + "(" + (1:1:size(mySs.A, 1)).' + ")");
end % if
end % function [ss, C] = seperateCfromSs(ss)
......
......@@ -110,14 +110,12 @@ for idx = 1 : numel(signalNames)
z = quantity.Domain("z", thisGrid{1});
end
quantityStruct = misc.setfield(quantityStruct, signalNames{idx}, ...
quantity.Discrete(thisSignalSorted, [t, z], ...
'name', signalNames{idx}));
quantity.Discrete(thisSignalSorted, [t, z], 'name', signalNames{idx}));
else
quantityStruct = misc.setfield(quantityStruct, signalNames{idx}, ...
quantity.Discrete( ...
simOutput(:, strcmp(outputNamesUnenumerated, signalNames{idx})), t, ...
'name', signalNames{idx}));
quantity.Discrete(simOutput(:, strcmp(outputNamesUnenumerated, signalNames{idx})), t, ...
'name', signalNames{idx}));
end
end
end
......
function [myOde, trackingSum, spectrumIndividual] = getMinimalInternalModel(...
function [myOde, spectrumIndividual] = getMinimalInternalModel(...
S, inputVectorMode, numberOfCopies, ...
stateName, trackingErrorSignalName, outputSignalName, referenceSignalName)
stateName, internalModelInputName, outputSignalName, referenceSignalName)
%misc.getMinimalInternalModel returnes the state space model myOde which is an
%misc.ss.Odes object and represents an internal model based on the signal model
%dynamics defined by S.
......@@ -27,17 +27,23 @@ function [myOde, trackingSum, spectrumIndividual] = getMinimalInternalModel(...
% (default: 'internalModel')
%
% mySs = misc.getMinimalInternalModel(S, inputVectorMode, numberOfCopies, ...
% stateName, controlOutputName) the inputName-property of the resulting
% stateName will be set to controlOutputName (default: 'plant.controlOutput').
% stateName, internalModelInputName) the inputName-property of the resulting
% state space will be set to controlOutputName (default: 'trakcingError').
%
% mySs = misc.getMinimalInternalModel(S, inputVectorMode, numberOfCopies, ...
% stateName, internalModelInputName, outputSignalName, referenceSignalName)
% additional output of the internal model state space will be
% internalModelInputName = outputSignalName - referenceSignalName.
% The InputName are outputSignalName and referenceSignalName instead of internalModelInputName.
arguments
S (:, :) double;
inputVectorMode (1, 1) string = "minimal";
numberOfCopies (1, 1) double = 1;
stateName string = "internalModel";
trackingErrorSignalName string = "trackingError";
internalModelInputName string = "trackingError";
outputSignalName string = "controlOutput";
referenceSignalName string = "reference";
referenceSignalName string = string();
end % arguments
% Smin: find minimal representation of S
......@@ -65,13 +71,24 @@ end
mySs = ss(sMin, B, eye(size(sMin)), []);
mySs = misc.ss.setSignalName(mySs, "output", stateName, size(mySs.C, 1));
mySs = misc.ss.setSignalName(mySs, "input", trackingErrorSignalName, size(mySs.B, 2));
if strlength(referenceSignalName) > 0
% implement tracking error via sum
% internalModelInputName = outputSignalName - referenceSignalName
mySs = misc.ss.setSignalName(mySs, "input", internalModelInputName, size(mySs.B, 2));
% get sum to create tracking error signal in simulation, i.e. a sum block:
trackingSum = sumblk(char(internalModelInputName + ...
"=" + outputSignalName + "-" + referenceSignalName), ...
numberOfCopies);
mySs = misc.ss.connect(trackingSum.InputName, [trackingSum.OutputName; mySs.OutputName], mySs, trackingSum);
else
% feed internal model via outputSignalName
mySs = misc.ss.setSignalName(mySs, "input", internalModelInputName, size(mySs.B, 2));
end
myOde = misc.ss.Odes(mySs, stateName);
% get sum to create tracking error signal in simulation, i.e. a sum block:
trackingSum = sumblk(char(trackingErrorSignalName + ...
"=" + outputSignalName + "-" + referenceSignalName), ...
numberOfCopies);
end % getMinimalInternalModel()
function [sMin, lengthBlocks] = minimalDynamicMatrix(S)
......
......@@ -162,35 +162,3 @@ BC = B*C;
testCase.verifyTrue(numeric.near(bc, BC.on()));
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment