Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LRT_infinite_dimensional_systems
conI
Commits
673d68bc
Commit
673d68bc
authored
Oct 14, 2019
by
Jakob Gabriel
Browse files
quantity.Discrete: changed constructor, such that init with empty i.e. quantity.Discrete([]) works
parent
038b06a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
+quantity/Discrete.m
View file @
673d68bc
...
...
@@ -48,31 +48,23 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
% name-value-pair-syntax in varargin.
% to allow the initialization as object array, the constructor
% must be allowed to be called without arguments
if
nargin
>
0
% must be allowed to be called without arguments, i.e. nargin == 0.
% Then no parameters are set.
if
nargin
==
1
% if nargin == 1 it can be a conversion of child-classes or an empty
% object
if
isa
(
valueOriginal
,
'quantity.Discrete'
)
% allows the conversion of a quantity object without
% extra check if the object is already from class
% quantity.Discrete
obj
=
valueOriginal
;
return
end
%% allow initialization of empty objects:
valueOriginalSize
=
size
(
valueOriginal
);
S
=
num2cell
(
valueOriginalSize
);
if
any
(
valueOriginalSize
==
0
)
% If the size is specified in the arguements, it should
% be chosen instead of the default size from the
% valueOriginal.
myParser
=
misc
.
Parser
();
myParser
.
addParameter
(
'size'
,
[
S
{:}]);
myParser
.
parse
(
varargin
{:});
obj
=
quantity
.
Discrete
.
empty
(
myParser
.
Results
.
size
);
return
;
else
% empty object. this is neede for instance, to create
% quantity.Discrete([]), which is useful for creating default
% values.
obj
=
quantity
.
Discrete
.
empty
(
size
(
valueOriginal
));
end
elseif
nargin
>
1
%% input parser
myParser
=
misc
.
Parser
();
...
...
@@ -90,6 +82,19 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
myGridName
=
{
myParser
.
Results
.
gridName
};
end
%% allow initialization of empty objects:
valueOriginalSize
=
size
(
valueOriginal
);
if
any
(
valueOriginalSize
==
0
)
% If the size is specified in the arguements, it should
% be chosen instead of the default size from the
% valueOriginal.
myParser
=
misc
.
Parser
();
myParser
.
addParameter
(
'size'
,
valueOriginalSize
((
1
+
numel
(
myGridName
)):
end
));
myParser
.
parse
(
varargin
{:});
obj
=
quantity
.
Discrete
.
empty
(
myParser
.
Results
.
size
);
return
;
end
%% get the sizes of obj and grid
if
iscell
(
valueOriginal
)
if
isempty
(
valueOriginal
{
1
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment