Commit 8e67b835 authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

More flexibility for the qunatity.Domain/find method

parent da24ab21
......@@ -94,16 +94,28 @@ classdef (InferiorClasses = {?quantity.EquidistantDomain}) Domain < handle & mat
% names NAME1 and NAME2 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.
% DOMAIN.name in the object-array of quantity.Domain OBJ. It
% only looks for the domain name and not the grid.
%
% d = find(OBJ, { NAME or DOMAIN}) the NAME or the DOMAIN to
% be found can also be defined by cell-array.
names = {obj.name};
if isa(domain, 'quantity.Domain')
searchName = domain.name;
searchName = {domain.name};
elseif ischar(domain)
searchName = {domain};
elseif iscell(domain)
searchName = domain;
else
error('Not implemented yet')
end
if numel(searchName) > 1
d = obj.find(searchName{:});
return
end
d = obj(strcmp(names, searchName));
for it = 1 : numel(varargin)
......
......@@ -3,6 +3,36 @@ function [tests] = testDomain()
end
function setupOnce(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.TestData.z = z;
testCase.TestData.a = a;
testCase.TestData.b = b;
testCase.TestData.c = c;
testCase.TestData.d = d;
end
function testFind(testCase)
z = testCase.TestData.z;
a = testCase.TestData.a;
b = testCase.TestData.b;
c = testCase.TestData.c;
d = testCase.TestData.d;
testCase.verifyEqual( d.find('a'), a)
testCase.verifyEqual( d.find('b', 'c'), [b c])
testCase.verifyEqual( d.find({'b', 'c'}), [b c])
testCase.verifyEqual( d.find(b), b);
testCase.verifyEqual( d.find({a c}), [a c])
testCase.verifyEqual( d.find([a b]), [a b])
end
function testGet(testCase)
......
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