It looks like the festi property only depends on the strengthClass property. You could create a set method for strengthClass which updates festi.
set method for class
1 次查看(过去 30 天)
显示 更早的评论
Hy I got this class, that i use to store some data. i made the festi property dependant but now i realize that i have to call this function really often ( 100 000) during the program and since there are several awitches and severeal other defenitions within it ( i didt copy the hole code) it makes it to slow. actually i use the values a lot but i dont often change the values.
so it would be nice to save the container that would make it fatser because then i could reach the values throught the container without going throught all the swiches and ifs.
i copied my new solution unter the first try.
i would be thankfull for any help thanx
classdef material
properties
name %string
strengthClass %string
end%properties
properties (Dependent)
festi % dictionary or containers.Map
end%properties
methods
function m = material(name,strengthClass)
m.name=name;
m.strengthClass = strengthClass;
end
function obj = get.festi(obj)
F_NadelundLaub=[14,16... % some matriy with date
keys_NHuLH={'fmk','ft0k','ft90k','fc0k'};
F_BSH=[24,.... other matrix with data
...
if strcmp(obj.name,'Nadelholz')
switch obj.strengthClass
case 'C14'
values =F_NadelundLaub(:,1);
case 'C16'...
end
end
end %eleseif
val = containers.Map(keys,values);
end
end %methods
end %CLASS
% the other way
classdef material
properties
name %string
strengthClass %string
festi % dictionary
end%properties
methods
function m = material(name,strengthClass)
m.name=name;
m.strengthClass = strengthClass;
m.festi = Festigkeitswerte2(m.name,m.strengthClass); % this one works
end
end %methods
end %CLASS
% to change it outside the class i could use:
instanceofMaterial.festi = Festigkeitswerte2('Nadelholz','C14')
% this one works too but im looking for a mor eleagant way
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!