-
Notifications
You must be signed in to change notification settings - Fork 0
/
Material.m
48 lines (33 loc) · 1.57 KB
/
Material.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
classdef Material
properties
name
density
end
properties (Access = private)
energy
massAttenuationCoefficientPerDensity
end
methods
function obj = Material(MaterialName, density)
materialFile = load([MaterialName, '.mat']);
obj.name = MaterialName;
obj.density = density;
obj.energy = materialFile.data(:,1);
obj.massAttenuationCoefficientPerDensity = materialFile.data(:,2);
end
function AttenuationCoefficient = getAttenuationCoefficient(obj, energy)
% getAttenuationCoefficient() to calculate the mass attenuation
% coefficient for a given energy and density
if any(ismember(obj.energy, energy))
AttenuationCoefficientPerDensity = obj.massAttenuationCoefficientPerDensity(obj.energy == energy);
else
% If the corresponding energy is not present then we
% interpolate the mass attenuation coefficient per density
AttenuationCoefficientPerDensity = interp1(obj.energy, obj.massAttenuationCoefficientPerDensity, energy);
end
% Compute attenuation coefficient using attenuation coefficient
% per density and the density
AttenuationCoefficient = AttenuationCoefficientPerDensity * obj.density;
end
end
end