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

Restored the ability to concatenate quantity.Discrete objects with different grids.

Added the ability to concatenate quantity.Discrete objects with numerical values. In this case, for the numerical value a quantity.Discrete object is initialized.
parent 5bd68e1b
......@@ -418,9 +418,33 @@ classdef (InferiorClasses = {?quantity.Symbolic, ?quantity.Operator}) Discrete
if nargin == 1
objCell = {a};
else
objCell = [{a}, varargin(:)'];
for k = 1:numel(varargin)
if isa(varargin{k}, 'quantity.Discrete')
o = varargin{k};
else
value = varargin{k};
for l = 1:numel(value)
M(:,l) = repmat(value(l), prod(a(1).gridSize), 1);
end
M = reshape(M, [a(1).gridSize, size(value)]);
o = quantity.Discrete( M, ...
'gridName', a(1).gridName, ...
'grid', a(1).grid);
end
objArgin{k} = o;
end
objCell = [{a}, objArgin(:)'];
end
[fineGrid, fineGridName] = getFinestGrid(objCell{:});
for it = 1 : (numel(varargin) + 1) % +1 because the first entry is a
objCopyTemp = copy(objCell{it});
objCell{it} = objCopyTemp.changeGrid(fineGrid, fineGridName);
end
assertSameGrid(objCell{:});
argin = [{dim}, objCell(:)'];
c = builtin('cat', argin{:});
......
......@@ -20,15 +20,12 @@ testCase.verifyTrue(all(size(ABA) == [2, 3]));
t = linspace(0, pi, 13)';
C = quantity.Discrete({sin(t); cos(t)}, 'grid', {t}, 'gridName', 't');
didNotWork = false;
AC = [A; C];
try
AC = [A, C];
catch ex
didNotWork = true;
end
testCase.verifyTrue(all(size(AC) == [4, 1]));
testCase.verifyTrue(didNotWork);
A0s = [A, zeros(2,3)];
testCase.verifyTrue(all(all(all(A0s(:, 2:end).on() == 0))))
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