Skip to content

Instantly share code, notes, and snippets.

@ctimmins
Created March 3, 2015 01:50
Show Gist options
  • Save ctimmins/cb7bc98c3b9d6bdb53b2 to your computer and use it in GitHub Desktop.
Save ctimmins/cb7bc98c3b9d6bdb53b2 to your computer and use it in GitHub Desktop.
hAi_ij = [ 'D4'; 'D4'; 'D4'; 'D6'; 'D6'; 'D6'; 'D7'; 'DA'; 'DA'; 'DA'; 'DC'; 'DB'; 'DC'; 'DD'; 'DE'; 'DC'; 'DF'; 'DF'; 'E0'; 'DE'; 'E0'; 'E1'; 'E0'; 'DE'; 'E1'; 'E1'; 'E1'; 'E2'; 'E3'; 'E4'; 'E5'; 'E4'; 'E7'; 'E6'; 'E6'; 'E7'; 'E9'; 'E8'; 'E9'; 'EA'; 'E9'; 'EB'; 'EA'; 'EB'; 'E9'; 'EB'; 'EC'; 'ED'; 'EB'; 'EC'; 'EC'; 'EF'; 'EC'; 'EE'; 'EE'; 'F0'; 'EC'; 'ED'; 'EE'; 'EF'; 'EC'; 'EC'; 'EC'; 'EF'];
hBi_ij = [ 'BC'; 'BC'; 'BC'; 'BC'; 'BC'; 'BC'; 'C4'; 'C4'; 'C4'; 'C4'; 'CD'; 'C4'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'CD'; 'D5'; 'D5'; 'D5'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'DE'; 'E6'; 'DE'; 'DE'; 'DE'; 'E6'; 'DE'; 'DE'; 'E6'; 'EF'; 'DE'; 'DE'; 'DE'; 'E6'];
hdelta_alpha_ij = [ '00'; '29'; '30'; '1F'; '26'; '5D'; '5D'; '41'; '41'; '78'; '7C'; '67'; '5D'; '94'; '9B'; '83'; '6E'; 'AF'; 'AC'; '97'; '7C'; 'BA'; 'C1'; 'A8'; '86'; 'C1'; 'CB'; 'AC'; '86'; 'C4'; 'C4'; 'A8'; '82'; 'B9'; 'C7'; 'A5'; '82'; 'B6'; 'BD'; '9A'; '7B'; 'AF'; 'B2'; '93'; '78'; 'A5'; 'AC'; '89'; '6E'; '93'; '9E'; '78'; '60'; '86'; '86'; '67'; '48'; '67'; '6D'; '4B'; '29'; '4F'; '52'; '25' ];
hAcp = 'E6';
hBcp = 'CD';
halphacp_l = '18';
halphacp_h = '09';
hTGC = '00';
hBi_scale = '08';
halpha0_l = '39';
halpha0_h = '98';
halpha_scale = '29';
hdelta_alpha_scale = '22';
he_l = '00';
he_h = '80';
@ctimmins
Copy link
Author

ctimmins commented Mar 3, 2015

hexVth_L = '68';
hexVth_H = '1A';
hexKt1_L = '77';
hexKt1_H = '5B';
hexKt2_L = '34';
hexKt2_H = '12';

@ctimmins
Copy link
Author

ctimmins commented Mar 3, 2015

if Acp < ToCheckHalf
Acp = Acp;
else
Acp = Acp - ToCheckFull;
end

if Bcp < ToCheckHalf
Bcp = Bcp;
else
Bcp = Bcp - ToCheckFull;
end

if Ai_ij < ToCheckHalf
Ai_ij = Ai_ij;
else
Ai_ij = Ai_ij - ToCheckFull;
end

if Bi_ij < ToCheckHalf
Bi_ij = Bi_ij;
else
Bi_ij = Bi_ij - ToCheckFull;
end

if TGC < ToCheckHalf
TGC = TGC;
else
TGC = TGC - ToCheckFull
end

@ctimmins
Copy link
Author

ctimmins commented Mar 3, 2015

%input data
hexVcp = compensation;
hexVir = [ir];
%convert to decimal values
Vcp = hex2dec(hexVcp);
Vir = hex2dec(hexVir);
%perform sign checks
if Vcp < halfRange
Vcp = Vcp;
else
Vcp = Vcp - fullRange;
end

if Vir < halfRange
Vir = Vir;
else
Vir = Vir - fullRange;
end

%computations
Vcp_off_comp = Vcp -(Acp +(Bcp./(2.^(Bi_scale))).(Ta-Ta_0));
Vir_ij_off_comp = Vir-(Ai_ij +(Bi_ij./(2.^(Bi_scale))).
(Ta-Ta_0));
Vir_ij_TGC_comp = Vir_ij_off_comp-((TGC./32)._Vcp_off_comp);
epsilon = (256._e_h + e_l)/32768;
Vir_compensated = Vir_ij_TGC_comp./epsilon;
alpha_ij = (256.alpha0_h+alpha0_l-((TGC./32).(256.*alphacp_h+alphacp_l)))/2.^alpha_scale + (delta_alpha_ij./(2.^(delta_alpha_scale)));
To_ij = ((Vir_compensated./alpha_ij)+(Ta+273.15).^4).^(1/4) - 273.15;
To_ij = vec2mat(To_ij,16);
t_out = To_ij;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment