Commit 5fad837a authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

Added find function to quantity.Domain

parent 90c02236
......@@ -75,26 +75,27 @@ classdef Domain < handle & matlab.mixin.CustomDisplay
s = [obj.n];
end
% function s = eq(obj, obj2)
%
% if isempty(obj) && isempty(obj2)
% % if both are empty -> they are equal
% s = true;
% elseif isempty(obj) || isempty(obj2)
% % if only one domain is empty -> they are not equal
% s = false;
% else
% % if both are not empty: check if the grids and the
% % gridNames are equal
% s = all(obj.gridLength == obj2.gridLength);
%
% for k = 1:numel(obj)
% s = s && all(obj(k).grid == obj2(k).grid);
% s = s && strcmp(obj(k).name, obj2(k).name);
% end
% end
% end
%
function d = find(obj, domain)
% FIND a domain in object-array of quantity.Domain
%
% d = find(OBJ, NAME) returns the domain with the name NAME
% of the object-array of quantity.Domain OBJ.
%
% d = find(OBJ, DOMAIN) find the domain with the name
% DOMAIN.name in the object-array of quantity.Domain OBJ.
names = {obj.name};
if isa(domain, 'quantity.Domain')
searchName = domain.name;
elseif ischar(domain)
searchName = domain;
else
error('Not implemented yet')
end
i = strcmp(names, searchName);
d = obj(i);
end
function l = ne(obj, obj2)
l = ~(obj == obj2);
end
......
......@@ -5,6 +5,21 @@ end
function setupOnce(testCase)
end
function testGet(testCase)
z = linspace(0, pi, 3);
a = quantity.Domain('a', z);
b = quantity.Domain('b', z);
c = quantity.Domain('c', z);
d = [a b c];
testCase.verifyEqual(d.find('a'), a);
testCase.verifyEqual(d.find(b), b);
testCase.verifyEqual(d.find('c'), c);
end
function testEquality(testCase)
d = quantity.Domain('d', 0);
......
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