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

Fixed rounding bug in misc.subanimate.

Further minor fixes ...
parent 5fad837a
......@@ -7,6 +7,7 @@ myParser.addParameter('frames', 201);
myParser.addParameter('timeGridName', 't');
myParser.addParameter('spatialGridName', 'z');
myParser.addParameter('compareWith', []);
myParser.addParameter('myFigure', [] );
myParser.parse(varargin{:});
lr.t = x.gridOf(myParser.Results.timeGridName);
lr.z = x.gridOf(myParser.Results.spatialGridName);
......@@ -19,7 +20,9 @@ if doCompare
lr.xReference = myParser.Results.compareWith.on({lr.t, lr.z}, {'t', 'z'});
end
figure();
if isempty(myParser.Results.myFigure)
figure();
end
subplotCell = cell(size(x));
for it = 1 : numel(x)
subplotCell{it}.s = subplot(numel(x),1,it);
......@@ -37,7 +40,7 @@ for it = 1 : numel(x)
aTemp.TickLabelInterpreter = 'latex';
end
for k = 1 : round(numel(lr.t)/myParser.Results.frames) : numel(lr.t)
for k = 1 : ceil(numel(lr.t)/myParser.Results.frames) : numel(lr.t)
for it = 1 : numel(x)
subplotCell{it}.s;
clearpoints(subplotCell{it}.x)
......
function quantity(A)
%mustBe.quantity Validate that A is quatratic Matrix or else throw
% an error.
%mustBe.quantity
%
warning('DEPRICATED? Is this mustBe.quantity function really required?')
if ~isempty(A) && ~isa(A, 'quantity.Discrete')
error('Value assigned to Data property must be a quantity.Discrete.')
end
......
classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mixin.Copyable & matlab.mixin.CustomDisplay
properties (SetAccess = protected)
% Discrete evaluation of the continuous quantity
valueDiscrete double;
......@@ -118,8 +119,9 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
% set valueDiscrete
for k = 1:numel(valueOriginal)
if numel(myDomain) == 1
% TODO: Which case is this? Why does it need extra
% treatment?
% for quantities on a single domain, ensure that
% the discrete values are stored as column-vector
% by using the (:) operator.
obj(k).valueDiscrete = valueOriginal{k}(:); %#ok<AGROW>
else
obj(k).valueDiscrete = valueOriginal{k}; %#ok<AGROW>
......@@ -1726,7 +1728,15 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
% system of linear equations x*A = B for x. The matrices A and
% B must contain the same number of columns"
x = B * inv(A);
end
function x = rdivide(A, B)
if isnumeric(A)
x = quantity.Discrete( A ./ B.on(), 'size', size(B), ...
'domain', B(1).domain, 'name', ['1 ./ ' B(1).name]);
else
error('Not yet implemented')
end
end
function P = matTimes(a, b)
......
classdef Domain < handle & matlab.mixin.CustomDisplay
classdef Domain < handle & matlab.mixin.CustomDisplay & matlab.mixin.Copyable
%DOMAIN class to describes a range of values on which a function can be defined.
% todo:
......@@ -56,6 +56,19 @@ classdef Domain < handle & matlab.mixin.CustomDisplay
function upper = get.upper(obj)
upper = max( obj.grid );
end
end
methods (Access = public)
function d = copyAndRename(obj, newName)
d = obj.copy();
newName = misc.ensureIsCell(newName);
assert(length(newName) == length(d), 'For the renaming of a copy of a domain, the numebr of new names must be equal the number of the domains');
for k = 1:length(newName)
d(k).name = newName{k};
end
end
function nd = ndims(obj)
......
......@@ -113,7 +113,7 @@ classdef PolynomialOperator < handle & matlab.mixin.Copyable
% is evaluated.
myParser = misc.Parser();
myParser.addParameter('domain', y.domain);
myParser.addParameter('domain', y(1).domain);
myParser.addParameter('n', length(obj));
myParser.parse(varargin{:});
......
......@@ -5,12 +5,12 @@ classdef TimeDelayOperator < handle & matlab.mixin.Copyable
% exp(-s coefficient(z) ) * H(s) <-> h(t + coefficient(z))
properties
coefficient {mustBe.quantity};
coefficient (1,1) quantity.Discrete;
end
properties (Access = protected)
spatialDomain_inner quantity.Domain;
timeDomain_inner quantity.Domain;
timeDomain_inner (1,1) quantity.Domain;
isZero logical = false;
end
......@@ -26,16 +26,21 @@ classdef TimeDelayOperator < handle & matlab.mixin.Copyable
% parameters, a spatial domain can be specified by the name
% 'spatialDomain'.
arguments
coefficient;
timeDomain;
coefficient = quantity.Discrete;
timeDomain (1,1) = quantity.Domain;
optionalArgs.spatialDomain = coefficient.domain;
optionalArgs.isZero logical = false;
end
obj.coefficient = coefficient;
obj.timeDomain_inner = timeDomain;
obj.spatialDomain_inner = optionalArgs.spatialDomain;
obj.isZero = optionalArgs.isZero;
if nargin > 0
for k = 1:numel(coefficient)
obj(k).coefficient = coefficient(k);
end
[obj.timeDomain_inner] = deal(timeDomain);
[obj.spatialDomain_inner] = deal(optionalArgs.spatialDomain);
[obj.isZero] = deal(optionalArgs.isZero);
end
end
function d = applyTo(obj, h, optionalArgs)
......@@ -61,7 +66,9 @@ classdef TimeDelayOperator < handle & matlab.mixin.Copyable
for j = 1 : m
for k = 1 : l
if ~obj(i, j).isZero
d(i, k) = d(i, k) + h(j, k).compose( obj.t + obj(i, j).coefficient, 'domain', optionalArgs.domain );
d(i, k) = d(i, k) + ...
h(j, k).compose( obj.t + obj(i, j).coefficient, ...
'domain', optionalArgs.domain );
end
end
end
......@@ -80,6 +87,9 @@ classdef TimeDelayOperator < handle & matlab.mixin.Copyable
end
function d = diag(obj)
% DIAG Diagonal matrices and diagonals of a matrix.
% DIAG(OBJ) puts the entries of the vector OBJ onto the main
% diagonal of matrix. The other values are filled with zero.
n = length(obj);
idx = 1:n;
......
......@@ -39,6 +39,13 @@ testCase.verifyEqual(td.delay.constant.coefficient, ...
td.coefficient.constant);
testCase.verifyEqual( td.delay.variable.coefficient, td.coefficient.variable);
coeffs = [testCase.TestData.coefficient.constant, ...
testCase.TestData.coefficient.variable];
D = signals.TimeDelayOperator(coeffs);
testCase.verifyEqual([D.coefficient], coeffs )
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