% example code to utilize the coefficients provided on the website
% https://www.amri.ninds.nih.gov/cgi-bin/phantomrecipe
% 
% version 0.1 Qi Duan 2014-05-22
% - creation
% version 0.2 Qi Duan 2014-08-29
% - updated the way to calculate the properties

Sugar_Water_Ratio =1436.463554/1000;
Salt_Water_Ratio = 60.133680/1000;
Freq = 297.4e6; %Hz


f_scale =      1e-09;
sugar_scale = 1;
salt_scale =   100;

%prepare data
x = Sugar_Water_Ratio * sugar_scale;
y = Salt_Water_Ratio * salt_scale;
z = Freq * f_scale;

%load polynomials
PM_e = load('power_matrix.txt');
p_e = load('coef_e.txt');
PM_s = PM_e;
p_s = load('coef_s.txt');


%calculate e
e = sum(p_e.*x.^PM_e(:,1).*y.^PM_e(:,2).*z.^PM_e(:,3));

%calculate s
s = sum(p_s.*x.^PM_s(:,1).*y.^PM_s(:,2).*z.^PM_s(:,3));


%display
fprintf('e_r = %g, s= %g (S/m)\n',e,s);