Skip to content
GitLab
Menu
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
7ded3f9a
Commit
7ded3f9a
authored
Oct 26, 2020
by
Jakob Gabriel
Browse files
quantity.Domain.replace
parent
f3be9c05
Changes
2
Hide whitespace changes
Inline
Side-by-side
+quantity/Domain.m
View file @
7ded3f9a
...
...
@@ -250,6 +250,18 @@ classdef (InferiorClasses = {?quantity.EquidistantDomain}) Domain < ...
rest
=
obj
(
~
logicalIdxToBeRemoved
);
end
% remove()
function
obj
=
replace
(
obj
,
toBeReplaced
)
% REPLACE replaced a domain with another domain.
%
% obj = replace(obj, toBeReplaced) replaces the element of the obj with the same name
% as the toBeReplaced domain with the new domain toBeRelaced.
thisIdx
=
obj
.
index
(
toBeReplaced
);
if
thisIdx
>
0
obj
(
thisIdx
)
=
toBeReplaced
;
end
end
% replace()
function
[
idx
,
log
]
=
index
(
obj
,
searchName
,
position
)
%% GRIDINDEX returns the index of the grid
% [idx, log] = index(obj, names) searches in the name
...
...
+unittests/+quantity/testDomain.m
View file @
7ded3f9a
...
...
@@ -2,6 +2,26 @@ function [tests] = testDomain()
tests
=
functiontests
(
localfunctions
);
end
function
testReplace
(
tc
)
z
=
linspace
(
0
,
pi
,
3
);
a
=
quantity
.
Domain
(
"a"
,
z
);
b
=
quantity
.
Domain
(
"b"
,
z
);
c
=
quantity
.
Domain
(
"c"
,
z
);
d
=
[
a
b
c
];
d
=
d
.
replace
(
quantity
.
Domain
(
"b"
,
linspace
(
0
,
1
,
2
)));
tc
.
verifyEqual
([
d
.
name
],
[
"a"
;
"b"
;
"c"
]
.'
);
tc
.
verifyEqual
(
d
(
1
)
.
grid
,
linspace
(
0
,
pi
,
3
)
.'
);
tc
.
verifyEqual
(
d
(
3
)
.
grid
,
linspace
(
0
,
pi
,
3
)
.'
);
tc
.
verifyEqual
(
d
(
2
)
.
grid
,
linspace
(
0
,
1
,
2
)
.'
);
d
=
d
.
replace
(
quantity
.
Domain
(
"e"
,
linspace
(
2
,
3
,
4
)));
tc
.
verifyEqual
([
d
.
name
],
[
"a"
;
"b"
;
"c"
]
.'
);
tc
.
verifyEqual
(
d
(
1
)
.
grid
,
linspace
(
0
,
pi
,
3
)
.'
);
tc
.
verifyEqual
(
d
(
3
)
.
grid
,
linspace
(
0
,
pi
,
3
)
.'
);
tc
.
verifyEqual
(
d
(
2
)
.
grid
,
linspace
(
0
,
1
,
2
)
.'
);
end
% testReplace
function
setupOnce
(
tc
)
z
=
linspace
(
0
,
pi
,
3
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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