Commit d4bad356 authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

Added applyOn function to the operator. It allows the evaluation of differential parameterizations.

parent 960b0569
......@@ -49,6 +49,22 @@ classdef Operator < handle & matlab.mixin.Copyable
s = prsr.Results.s;
%TODO assert that A has entries with the same size
if isa(A, 'sym') && symvar(A) == prsr.Results.s
% if the matrix A is a symbolic expression which
% contains the algebraic representation of the
% operator, then the object can be generated if the
% symbolic expression is converted into the right form
% TODO: this works only for constant coefficients:
% catch the case if the coefficients are variable:
assert(length(symvar(A)) == 1, 'Not yet implemented')
A = num2cell( double( polyMatrix.polynomial2coefficients(A, prsr.Results.s) ), ...
[1, 2]);
end
if iscell(A)
for k = 1 : numel(A)
if isnumeric(A{k})
......@@ -104,7 +120,7 @@ classdef Operator < handle & matlab.mixin.Copyable
myDomain = myParser.Results.domain;
n = myParser.Results.n;
value = 0;
value = zeros(size(obj(1).coefficient));
for k = 1:n
value = value + obj(k).coefficient * y.diff(k - 1, myDomain );
......
......@@ -39,25 +39,26 @@ end
function testApplyOn(testCase)
A = [0 1 0 0; 0 0 1 0; 0 0 0 1; 1:4];
B = [0 0 0 1]';
C = [1 0 0 0];
A = [0 1 0; 0 0 1; - (1:3)];
B = [0 0 1]';
C = [1 0 0];
sys = ss(A, B, C, []);
G = tf(sys);
detsIA = quantity.Operator(num2cell(flip(charpoly(A))));
adjB = quantity.Operator( adjoint(sym('s')*eye(size(A)) - A) * B );
denom = flip( G.Denominator{:} );
det = quantity.Operator(num2cell(denom));
t = sym('t', 'real')
y = quantity.Symbolic( t.^3 .* (1 - t).^3, ...
'grid', linspace(0,1), 'gridName', 't');
u = det.applyOn(y)
t = sym('t', 'real');
sol.y = quantity.Symbolic( t.^3 .* (1 - t).^3, ...
'grid', linspace(0, 1, 1e2), 'gridName', 't');
sol.u = detsIA.applyOn(sol.y);
sol.x = adjB.applyOn(sol.y);
[sim.y, sim.t, sim.x] = lsim(sys, sol.u.on(), sol.y.domain.grid, 'foh');
% deviation of final values:
dev.y = sim.y(end)
dev.x = sim.x(end, :)
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