Commit 4bc82c17 authored by Jakob Gabriel's avatar Jakob Gabriel
Browse files

misc.Gain & misc.ss*: changed implementation to strings-arrys from cell-arrays of chars.

parent c14fc999
......@@ -4,20 +4,18 @@ function mySs = add2signalName(mySs, signalType, position, newText)
% Example:
% misc.ss.add2signalName(ss(1, 1, [1; 1], [], 'OutputName', {'a', 'b'}), ...
% 'OutputName', 'front', 'ode.');
assert(any(strcmp(position, {'front', 'back'})));
assert(any(strcmp(signalType, {'OutputName', 'InputName'})));
assert(ischar(newText) || isstring(newText), 'prefix must be a char-array or string');
arguments
mySs ss;
signalType (1, 1) string {mustBeMember(signalType, ["OutputName", "InputName"])};
position (1, 1) string {mustBeMember(position, ["front", "back"])};
newText (1, 1) string;
end
assert(any(strcmp(position, ["front", "back"])));
assert(any(strcmp(signalType, ["OutputName", "InputName"])));
myNames = mySs.(signalType);
if strcmp(position, 'front')
for it = 1 : numel(myNames)
myNames{it} = [newText, myNames{it}];
end
elseif strcmp(position, 'back')
for it = 1 : numel(myNames)
myNames{it} = [myNames{it}, newText];
end
if strcmp(position, "front")
mySs.(signalType) = strcat(newText, string(mySs.(signalType)));
elseif strcmp(position, "back")
mySs.(signalType) = strcat(string(mySs.(signalType)), newText);
end
mySs.(signalType) = myNames;
end
\ No newline at end of file
......@@ -23,11 +23,11 @@ function myStateSpace = changeSignalName(myStateSpace, oldName, newName, varargi
% -------------------------------------------------------------------------
% input checks
if ~iscell(oldName)
oldName = {oldName};
if ~isstring(oldName)
oldName = string(oldName);
end
if ~iscell(newName)
newName = {newName};
if ~isstring(newName)
newName = string(newName);
end
myParser = misc.Parser();
myParser.addRequired('myStateSpace', @(v) isa(v, 'ss'));
......@@ -57,42 +57,42 @@ function myStateSpace = changeInputName(myStateSpace, oldName, newName)
oldInputName = misc.ss.removeEnumeration(myStateSpace.InputName, false);
for it = 1 : numel(oldName)
% input check:
if any(strcmp(oldName{it}, uniqueOldInputName))
assert(~any(strcmp(oldName{it}, newName)), ...
if any(strcmp(oldName(it), uniqueOldInputName))
assert(~any(strcmp(oldName(it), newName)), ...
'overlaps in oldName and newName are not supported for InputName-changes');
end
end
for it = 1 : numel(oldName)
if any(strcmp(oldName{it}, uniqueOldInputName))
% there is an InputName with the name oldName{it} to be replaced.
numberOfThisInput = sum(strcmp(oldInputName, oldName{it}));
if any(strcmp(newName{it}, uniqueOldInputName))
% there is already a InputName with the name of newName{it}
if any(strcmp(oldName(it), uniqueOldInputName))
% there is an InputName with the name oldName(it) to be replaced.
numberOfThisInput = sum(strcmp(oldInputName, oldName(it)));
if any(strcmp(newName(it), uniqueOldInputName))
% there is already a InputName with the name of newName(it)
% -> they are interconnected via thisConnectorGain
thisConnectorGain = ss([], [], [], ...
vertcat(eye(numberOfThisInput), eye(numberOfThisInput)), ...
'InputName', newName{it});
'InputName', newName(it));
thisConnectorGain = misc.ss.setSignalName(thisConnectorGain, 'output', ...
{oldName{it}, [newName{it}, 'tempChangeSignalName']}, ...
{numberOfThisInput, numberOfThisInput});
[oldName(it); newName(it) + "tempChangeSignalName"], ...
[numberOfThisInput; numberOfThisInput]);
myStateSpace = misc.ss.changeSignalName(myStateSpace, ...
newName{it}, [newName{it}, 'tempChangeSignalName'], 'output', false);
newName(it), newName(it) + "tempChangeSignalName", 'output', false);
else
% there is no InputName with the name of newName{it}
% -> thisConnectorGain is just an identy with input newName{it} and
% output oldName{it}
% there is no InputName with the name of newName(it)
% -> thisConnectorGain is just an identy with input newName(it) and
% output oldName(it)
thisConnectorGain = ss([], [], [], ...
vertcat(eye(numberOfThisInput)), ...
'InputName', newName{it}, 'OutputName', oldName{it});
'InputName', newName(it), 'OutputName', oldName(it));
end
inputNameIntermediate = misc.ss.removeEnumeration(myStateSpace.InputName, false);
newInputNames = [inputNameIntermediate(...
~strcmp(inputNameIntermediate, oldName{it}) & ...
~strcmp(inputNameIntermediate, [newName{it}, 'tempChangeSignalName']))];
if ~any(strcmp(newInputNames, newName{it}))
~strcmp(inputNameIntermediate, oldName(it)) & ...
~strcmp(inputNameIntermediate, newName(it) + "tempChangeSignalName"))];
if ~any(strcmp(newInputNames, newName(it)))
newInputNames = [newInputNames; ...
repmat(newName(it), sum(strcmp(oldInputName, oldName{it})), 1)];
repmat(newName(it), sum(strcmp(oldInputName, oldName(it))), 1)];
end
myStateSpace = misc.ss.connect(...
newInputNames, myStateSpace.OutputName, ...
......@@ -107,22 +107,22 @@ function myStateSpace = changeOutputName(myStateSpace, oldName, newName)
% OutputName property, replacing the strings, and setting them in the end again.
uniqueOldInputName = misc.ss.removeEnumeration(myStateSpace.OutputName, true);
for it = 1 : numel(newName)
assert(~any(strcmp(uniqueOldInputName, newName{it})), ...
'newName is already OutputName of myStateSpace - not implemented');
assert(~any(strcmp(uniqueOldInputName, newName(it))), ...
"newName is already OutputName of myStateSpace - not implemented");
end
% split signal names
oldOutputNames = misc.ss.removeEnumeration(myStateSpace.OutputName);
newOutputNames = misc.ss.removeEnumeration(myStateSpace.OutputName);
oldOutputNames = string(misc.ss.removeEnumeration(myStateSpace.OutputName));
%newOutputNames = misc.ss.removeEnumeration(myStateSpace.OutputName);
% Exchange names of newOutputNames cell array:
for it = 1 : numel(newName)
if ~isempty(strcmp(oldOutputNames, oldName{it})) ...
&& any(strcmp(oldOutputNames, oldName{it}))
[oldOutputNames{strcmp(oldOutputNames, oldName{it})}] = deal(newName{it});
if ~isempty(strcmp(oldOutputNames, oldName(it))) ...
&& any(strcmp(oldOutputNames, oldName(it)))
[oldOutputNames(strcmp(oldOutputNames, oldName(it)))] = deal(newName(it));
end
end
uniqueOutputNames = unique(oldOutputNames, 'stable');
outputLength = cellfun(@(v) sum(strcmp(oldOutputNames, v)), uniqueOutputNames);
uniqueOutputNames = unique(oldOutputNames, "stable");
outputLength = arrayfun(@(v) sum(strcmp(oldOutputNames, v)), uniqueOutputNames);
% set output names
myStateSpace = misc.ss.setSignalName(myStateSpace, 'output', uniqueOutputNames, outputLength);
myStateSpace = misc.ss.setSignalName(myStateSpace, "output", uniqueOutputNames, outputLength);
end
\ No newline at end of file
......@@ -23,11 +23,18 @@ function myStateSpace = setSignalName(myStateSpace, signalType, signalNames, sig
% input checks
assert(isa(myStateSpace, "ss"), "1st input must be state space model");
assert(iscell(signalNames), "signalNames must be a cell array");
assert(iscell(signalNames) || isstring(signalNames), "signalNames must be a string array or cell array");
assert(iscell(signalLength) || isvector(signalLength), "signalLength must be a cell array or a vector");
if iscell(signalLength)
signalLength = cell2mat(signalLength);
end
if isstring(signalNames)
oldSignalNames = signalNames;
signalNames = cell(size(oldSignalNames));
for it = 1 : numel(oldSignalNames)
signalNames{it} = char(oldSignalNames(it));
end
end
if strcmp(signalType, "input")
assert(size(myStateSpace, 2) == sum([signalLength(:)]), "signalLength does not fit to state space");
......@@ -44,9 +51,9 @@ myCurrentSignal = 1;
for it = 1 : numel(signalNames)
for jt = 1 : signalLength(it)
if signalLength(it) == 1
myNewSignalNames{myCurrentSignal} = char(signalNames{it});
myNewSignalNames{myCurrentSignal} = signalNames{it};
else
myNewSignalNames{myCurrentSignal} = [char(signalNames{it}), '(', num2str(jt), ')'];
myNewSignalNames{myCurrentSignal} = [signalNames{it}, '(', num2str(jt), ')'];
end
myCurrentSignal = myCurrentSignal + 1;
end
......
......@@ -12,10 +12,10 @@ classdef Gain < handle & matlab.mixin.Copyable
value (:,:); % value
% data about gain
inputType char; % type of input signal, for instance
% % 'control', 'disturbance', 'fault' etc
outputType cell; % type of output signal, for instance
% % 'measurement', 'ode', ...
inputType (1, 1) string; % type of input signal, for instance
% % "control", "disturbance", "fault" etc
outputType (:, 1) string; % type of output signal, for instance
% % "measurement", "ode", ...
lengthInput (1, 1) double; % number of columns of gain value
lengthOutput (:, 1) double; % number of rows of gain value per outputType
end % properties
......@@ -36,9 +36,9 @@ classdef Gain < handle & matlab.mixin.Copyable
if nargin > 0
% read input
myParser = misc.Parser();
myParser.addParameter('outputType', {'out'}, ...
myParser.addParameter("outputType", "out", ...
@(v) iscell(v) | ischar(v) | isstring(v));
myParser.addParameter('lengthOutput', size(value, 1), ...
myParser.addParameter("lengthOutput", size(value, 1), ...
@(v) isvector(v) & isnumeric(v));
myParser.parse(varargin{:});
......@@ -47,11 +47,7 @@ classdef Gain < handle & matlab.mixin.Copyable
if iscell(myParser.Results.outputType)
obj.outputType = myParser.Results.outputType;
else
obj.outputType = {myParser.Results.outputType};
end
for it = 1 : numel(obj.outputType)
% only a cell of chars works, but not a cell of strings.
obj.outputType{it} = char(obj.outputType{it});
obj.outputType = myParser.Results.outputType;
end
% set lengths
......@@ -71,16 +67,16 @@ classdef Gain < handle & matlab.mixin.Copyable
myGains = copy(b);
elseif isempty(b)
myGains = copy(a);
elseif isa(b, 'misc.Gains')
elseif isa(b, "misc.Gains")
myGains = b + a;
elseif isa(b, 'misc.Gain')
elseif isa(b, "misc.Gain")
if strcmp(b.inputType, a.inputType)
myGains = parallel(a, b);
else
myGains = misc.Gains(copy(a), copy(b));
end
else
error('misc.Gain can only be added with other Gain or misc.Gains');
error("misc.Gain can only be added with other Gain or misc.Gains");
end
end % plus()
......@@ -100,10 +96,10 @@ classdef Gain < handle & matlab.mixin.Copyable
end % exchange()
function mySeries = series(obj, nextGain)
if isa(nextGain, 'misc.Gain')
if isa(nextGain, "misc.Gain")
mySeries = misc.Gain(nextGain.inputType, obj.value * nextGain.value);
elseif isa(nextGain, 'misc.Gains') && (numel(nextGain.inputType) > 0)
elseif isa(nextGain, "misc.Gains") && (numel(nextGain.inputType) > 0)
mySeries = misc.Gain(nextGain.gain(1).inputType, obj.value * nextGain.gain(1).value);
for it = 2 : numel(nextGain.inputType)
mySeries = mySeries + ...
......@@ -119,7 +115,7 @@ classdef Gain < handle & matlab.mixin.Copyable
% check sizes
assert((obj.lengthInput == outputNext.lengthInput) ...
&& strcmp(obj.inputType, outputNext.inputType), ...
'Parallel outputs must be defined for same input length');
"Parallel outputs must be defined for same input length");
for jt = 1 : numel(outputNext.outputType)
if any(strcmp(myParallel.outputType, outputNext.outputType{jt}))
......@@ -132,9 +128,9 @@ classdef Gain < handle & matlab.mixin.Copyable
else
myParallel = ...
misc.Gain(obj.inputType, ...
[myParallel.value; outputNext.valueOfOutput(outputNext.outputType{jt})], ...
'outputType', [myParallel.outputType; outputNext.outputType{jt}], ...
'lengthOutput', [myParallel.lengthOutput; outputNext.lengthOutput(jt)]);
[myParallel.value; outputNext.valueOfOutput(outputNext.outputType(jt))], ...
"outputType", [myParallel.outputType; outputNext.outputType(jt)], ...
"lengthOutput", [myParallel.lengthOutput; outputNext.lengthOutput(jt)]);
end
end
end
......@@ -156,7 +152,7 @@ classdef Gain < handle & matlab.mixin.Copyable
end % blkdiag()
function value = inputType2sumblk(obj)
% returns the string [type(1), '+', type(2), '+', ...]
% returns the string: type(1) + "+" + type(2) + "+" + ...
value = obj.inputType;
end % inputType2sumblk()
......@@ -165,8 +161,8 @@ classdef Gain < handle & matlab.mixin.Copyable
% properties InputName and OutputName set according to inputType and
% outputType.
mySs = ss([], [], [], obj.value, ...
'InputName', obj.InputName, ...
'OutputName', obj.OutputName);
"InputName", obj.InputName, ...
"OutputName", obj.OutputName);
end % gain2ss()
function thisOutputRows = getOutputRows(obj, outputType)
......@@ -174,19 +170,19 @@ classdef Gain < handle & matlab.mixin.Copyable
thisOutputRows = sum(obj.lengthOutput(1:(outputIdx-1))) + (1 : obj.lengthOutput(outputIdx));
end % getOutputRows()
function newObj = gainOfOutput(obj, outputNames)
if ~iscell(outputNames)
outputNames = {outputNames};
function newObj = gainOfOutput(obj, outputTypes)
arguments
obj;
outputTypes (:, 1) string;
end
outputNames = outputNames(...
cellfun(@(v) any(strcmp(v, obj.outputType.')), outputNames));
if isempty(outputNames)
outputTypes = outputTypes(strcmp(obj.outputType, outputTypes));
if isempty(outputTypes)
newObj = misc.Gain();
else
newObj = misc.Gain(obj.inputType, ...
obj.valueOfOutput(outputNames), ...
'outputType', outputNames, ...
'lengthOutput', obj.lengthOfOutput(outputNames));
obj.valueOfOutput(outputTypes), ...
"outputType", outputTypes, ...
"lengthOutput", obj.lengthOfOutput(outputTypes));
end
end % gainOfOutput()
......@@ -218,8 +214,8 @@ classdef Gain < handle & matlab.mixin.Copyable
obj = misc.Gain();
else
obj = misc.Gain(obj.inputType, newValue, ...
'outputType', newOutputType, ...
'lengthOutput', newLengthOutput);
"outputType", newOutputType, ...
"lengthOutput", newLengthOutput);
end
% obj.value = obj.value(myOutputRowsSelector, :);
% obj.outputType = obj.outputType(~strcmp(obj.outputType, outputType));
......@@ -233,7 +229,7 @@ classdef Gain < handle & matlab.mixin.Copyable
out = dps.Outputs();
for it = 1 : numel(obj.outputType)
out = out.add(dps.Output(...
obj.outputType{it}, 'input', copy(obj.gainOfOutput(obj.outputType{it}))));
obj.outputType(it), "input", copy(obj.gainOfOutput(obj.outputType(it)))));
end % for it = 1 : numel(obj.outputType)
end % dps.Output
......@@ -264,42 +260,42 @@ classdef Gain < handle & matlab.mixin.Copyable
function obj = strrepOutputType(obj, oldText, newText)
% replace strings in type
assert(ischar(oldText) || isstring(oldText), 'oldText must be a char-array or string');
assert(ischar(newText) || isstring(newText), 'newText must be a char-array or string');
assert(ischar(oldText) || isstring(oldText), "oldText must be a char-array or string");
assert(ischar(newText) || isstring(newText), "newText must be a char-array or string");
for it = 1 : numel(obj.outputType)
obj.outputType{it} = strrep(obj.outputType{it}, oldText, newText);
obj.outputType(it) = strrep(obj.outputType(it), oldText, newText);
end
end % strrepOutputType()
function obj = extendOutputType(obj, position, newText)
% extendOutputType adds a pre- or a postfix to obj.outputType
assert(any(strcmp(position, {'front', 'back'})));
assert(ischar(newText) || isstring(newText), 'prefix must be a char-array or string');
assert(any(strcmp(position, ["front", "back"])));
assert(ischar(newText) || isstring(newText), "prefix must be a char-array or string");
for it = 1 : numel(obj.outputType)
if strcmp(position, 'front')
obj.outputType{it} = [newText, obj.outputType{it}];
elseif strcmp(position, 'back')
obj.outputType{it} = [obj.outputType{it}, newText];
if strcmp(position, "front")
obj.outputType(it) = [newText, obj.outputType(it)];
elseif strcmp(position, "back")
obj.outputType(it) = [obj.outputType(it), newText];
end
end
end % extendOutputType()
function obj = strrepInputType(obj, oldText, newText)
% replace strings in type
assert(ischar(oldText) || isstring(oldText), 'oldText must be a char-array or string');
assert(ischar(newText) || isstring(newText), 'newText must be a char-array or string');
assert(ischar(oldText) || isstring(oldText), "oldText must be a char-array or string");
assert(ischar(newText) || isstring(newText), "newText must be a char-array or string");
obj.inputType = strrep(obj.inputType, oldText, newText);
end % strrepInputType()
function obj = extendInputType(obj, position, newText)
% extendInputType adds a pre- or a postfix to obj.inputType
assert(any(strcmp(position, {'front', 'back'})));
assert(ischar(newText) || isstring(newText), 'prefix must be a char-array or string');
assert(any(strcmp(position, ["front", "back"])));
assert(ischar(newText) || isstring(newText), "prefix must be a char-array or string");
if strcmp(position, 'front')
if strcmp(position, "front")
obj.inputType = [newText, obj.inputType];
elseif strcmp(position, 'back')
elseif strcmp(position, "back")
obj.inputType = [obj.inputType, newText];
end
end % extendInputType()
......@@ -310,11 +306,11 @@ classdef Gain < handle & matlab.mixin.Copyable
for jt = 1 : numel(obj.lengthOutput)
if (obj.lengthOutput(jt) == 1)
% no enumeration in this case
OutputName{myCounter} = [obj.outputType{jt}];
OutputName{myCounter} = char(obj.outputType(jt));
myCounter = myCounter + 1;
else
for it = 1 : sum(obj.lengthOutput(jt))
OutputName{myCounter} = [obj.outputType{jt}, '(', num2str(it), ')'];
OutputName{myCounter} = [char(obj.outputType(jt)), '(', num2str(it), ')'];
myCounter = myCounter + 1;
end
end
......@@ -325,10 +321,10 @@ classdef Gain < handle & matlab.mixin.Copyable
InputName = cell(sum(obj.lengthInput), 1);
if (obj.lengthInput == 1)
% no enumeration in this case
InputName{1} = obj.inputType;
InputName{1} = char(obj.inputType);
else
for it = 1 : sum(obj.lengthInput)
InputName{it} = [obj.inputType ,'(', num2str(it), ')'];
InputName{it} = [char(obj.inputType) ,'(', num2str(it), ')'];
end
end
end % get.InputName()
......@@ -343,7 +339,7 @@ classdef Gain < handle & matlab.mixin.Copyable
& all(strcmp(A.outputType, B.outputType));
end
if result && (nargin > 2)
result = isa(B, 'misc.Gain') & B.isequal(varargin{:});
result = isa(B, "misc.Gain") & B.isequal(varargin{:});
end
end % isequal()
......@@ -375,7 +371,7 @@ classdef Gain < handle & matlab.mixin.Copyable
else
myString = leftHandSide + " &=";
end
if ~isempty(obj.valueOfOutput(outputType)) && any(obj.valueOfOutput(outputType) ~=0, 'all')
if ~isempty(obj.valueOfOutput(outputType)) && any(obj.valueOfOutput(outputType) ~=0, "all")
myString = myString + misc.latexChar(obj.valueOfOutput(outputType)) ...
+ " " + inputName;
end
......
......@@ -16,13 +16,13 @@ classdef Gains < handle & matlab.mixin.Copyable
value (:,:); % gain value
% data about input
inputType (:, 1) cell; % inputType of input signal, for instance
% % 'control', 'disturbance', 'fault' etc
inputType (:, 1) string; % inputType of input signal, for instance
% % "control", "disturbance", "fault" etc
% % Input inputTypes must be unique, this is
% % verified in the constructor and in
% % add().
outputType (:, 1) cell; % type of output signal, for instance
% % 'measurement', 'ode', ...
outputType (:, 1) string; % type of output signal, for instance
% % "measurement", "ode", ...
lengthInput (:, 1) double; % number of columns of gain value
lengthOutput (:, 1) double; % number of rows of gain value
numTypes; % number of different input-object that
......@@ -37,7 +37,7 @@ classdef Gains < handle & matlab.mixin.Copyable
if nargin > 0
% all inputs of constructor in varargin are of Gain-inputType
obj.add(varargin{:});
assert(misc.isunique(obj.inputType), 'gain inputTypes must be unique');
assert(misc.isunique(obj.inputType), "gain inputTypes must be unique");
obj.verifySizes();
end % if nargin > 0
end % Gain() Constructor
......@@ -48,8 +48,8 @@ classdef Gains < handle & matlab.mixin.Copyable
for it = 1 : numel(varargin)
myGain = varargin{it};
if ~isempty(myGain)
if(isa(myGain, 'misc.Gain'))
if any(contains(obj.inputType, myGain.inputType))
if(isa(myGain, "misc.Gain"))
if any(strcmp(obj.inputType, myGain.inputType))
thisInputIndex = find(strcmp(obj.inputType, myGain.inputType));
obj.gain(thisInputIndex) = obj.gain(thisInputIndex) + myGain;
else
......@@ -59,16 +59,16 @@ classdef Gains < handle & matlab.mixin.Copyable
obj.gain(end+1) = myGain;
end
end
elseif(isa(myGain, 'misc.Gains'))
for it = 1 : myGain.numTypes
obj = obj.add(myGain.gain(it));
elseif(isa(myGain, "misc.Gains"))
for jt = 1 : myGain.numTypes
obj = obj.add(myGain.gain(jt));
end
else
error('only misc.Gain or misc.Gains can be added to misc.Gains-object');
error("only misc.Gain or misc.Gains can be added to misc.Gains-object");
end
end
end
assert(misc.isunique(obj.inputType), 'input inputTypes must be unique');
assert(misc.isunique(obj.inputType), "input inputTypes must be unique");
obj.verifySizes();
end % add()
......@@ -83,10 +83,10 @@ classdef Gains < handle & matlab.mixin.Copyable
c = b;
elseif isempty(b)
c = a;
elseif isa(a, 'misc.Gains') && isa(b, 'misc.Gain')
elseif isa(a, "misc.Gains") && isa(b, "misc.Gain")
c = copy(a);
c = c.add(b);
elseif isa(a, 'misc.Gains') && isa(b, 'misc.Gains')
elseif isa(a, "misc.Gains") && isa(b, "misc.Gains")
c = copy(a);
for it = 1 : b.numTypes
c.add(b.gain(it));
......@@ -152,8 +152,8 @@ classdef Gains < handle & matlab.mixin.Copyable
tempTail = thisTail.gain(it);
gainSeries.add(misc.Gain(tempTail.inputType, ...
thisHead.value * tempTail.value, ...
'outputType', thisHead.outputType, ...
'lengthOutput', thisHead.lengthOutput));
"outputType", thisHead.outputType, ...
"lengthOutput", thisHead.lengthOutput));
end
otherInputsOfHead = copy(gainHead);
otherInputsOfHead.remove(inputOfHeadObj);
......@@ -215,7 +215,7 @@ classdef Gains < handle & matlab.mixin.Copyable
function nameValuePairs = nameValuePairs(obj)
nameValuePairs = cell(1, 2*obj.numTypes);
for it = 1 : obj.numTypes
nameValuePairs{2*it-1} = [obj.gain(it).inputType, 'Gain'];
nameValuePairs{2*it-1} = [obj.gain(it).inputType, "Gain"];
nameValuePairs{2*it} = obj.gain(it);
end
end % nameValuePairs()
......@@ -226,28 +226,28 @@ classdef Gains < handle & matlab.mixin.Copyable
end %get.numTypes()
function inputType = get.inputType(obj)
inputType = {obj.gain(:).inputType}.';
inputType = vertcat(obj.gain(:).inputType);
end %get.inputType()
function outputType = get.outputType(obj)
outputType = {};
for it = 1 : obj.numTypes
outputType = unique([outputType(:); obj.gain(it).outputType(:)].', 'stable');
end
outputType = vertcat(obj.gain(:).outputType);
outputType = unique(outputType, "stable");
end % get.outputType()
function OutputName = get.OutputName(obj)
OutputName = {};
for it = 1 : obj.numTypes
OutputName = unique([OutputName(:); obj.gain(it).OutputName(:)], 'stable');
OutputName = [OutputName(:); obj.gain(it).OutputName(:)];
end
OutputName = unique(OutputName, "stable");
end % get.OutputName()
function InputName = get.InputName(obj)
InputName = {};
for it = 1 : obj.numTypes
InputName = unique([InputName(:); obj.gain(it).InputName(:)], 'stable');
InputName = [InputName(:); obj.gain(it).InputName(:)];
end
InputName = unique(InputName, "stable");
end % get.InputName()
function length = lengthOf(obj, inputType)
......@@ -303,36 +303,36 @@ classdef Gains < handle & matlab.mixin.Copyable
end % get.valueOf()
function sumblkString = outputType2sumblk(obj, varargin)
% returns the string [type(1), '+', type(2), '+', ...]
% returns the string [type(1) + "+" + type(2) + "+" + ...]
% if additionally an output 'append' is given as name-value pair, the
% string results in
% returns the string [type(1), append, '+', type(2), append, '+', ...]
myParser = misc.Parser();
myParser.addParameter('append', '', @(v) ischar(v) | isstring(v));
myParser.addParameter("append", "", @(v) ischar(v) | isstring(v));
myParser.parse(varargin{:});
sumblkString = '';
if numel(obj.outputType) > 0
for it = 1 : (numel(obj.outputType)-1)
sumblkString = [sumblkString, ...
obj.outputType{it}, myParser.Results.append, '+'];
obj.outputType(it), myParser.Results.append, "+"];
end
sumblkString = [sumblkString, obj.outputType{end}, myParser.Results.append];
sumblkString = [sumblkString, char(obj.outputType(end)), char(myParser.Results.append)];
end
end % inputType2sumblk()
function sumblkString = inputType2sumblk(obj, varargin)
% returns the string [type(1), '+', type(2), '+', ...]
% if additionally an input 'append' is given as name-value pair, the