mixin.SlectBy - GavriYashar/Matlab-Utilities GitHub Wiki
usage example
classdef MyClass < handle & mixin.SelectBy
properties (Access = private)
prop1(1,1) string = ""
end
properties (SetAccess = private)
prop2(1,1) double = 0;
end
methods (Access = public)
function obj = MyClass()
obj.prop1 = char(randi(26,[1,15]) + 65);
obj.prop2 = randi(10,1);
end
function p1 = getProp1(objs)
p1 = MyClass.reshapeT(objs, [objs.prop1]);
end
end
methods (Static = true)
function T = reshapeT(objs, T)
% e.g.: objs == goodOldSP.messstelle.Messstelle
% messobjekt = handleDA.reshapeT(objs, [objs.Messobjekt]);
T = reshape(T, size(objs));
end
end
end
rng(0)
mc(5,8,3) = MyClass();
for i = 1:numel(mc)
mc(i) = MyClass();
end
[mcSel, idx] = mc.selectByRegexpi("getProp1", "BX");
mcSel(1) =
MyClass with properties:
prop1: "LYVZSBXZSUULSFT"
prop2: 1
mcSel(2) =
MyClass with properties:
prop1: "BXQ[ONVGNYPWUQH"
prop2: 7
mcSel(3) =
MyClass with properties:
prop1: "UMTZVTDLQMCGWBX"
prop2: 1
find(idx)
ans =
1
38
89