Code covered by the BSD License

Files for the 2012 Webinar "Tips and Tricks - Getting Started Using Optimization with MATLAB"

Seth DeLand (view profile)

These are the files that were used for the demonstrations in the webinar.

tempCompCurve(x,Tdata)
```function F = tempCompCurve(x,Tdata)
%TEMPCOMPCURVE Calculate temperature curve given resistor and thermistor values
%   TEMPCOMPCURVE(X, TDATA) calculates the voltages at each point in TDATA
%   using the resistor and thermistor values stored in the X vector.
%
%   Syntax
%      F = tempCompCurve(x, Tdata)
%
%   See also RunThermistorExample, objectiveFunction

% Copyright (c) 2012, The MathWorks, Inc.
% All rights reserved.
%% Input voltage
Vin = 1.1;

%% Thermistor Calculations
% Values in x: R1 R2 R3 R4 RTH1(T_25degc) Beta1 RTH2(T_25degc) Beta2
% Thermistors are represented by:
%   Room temperature is 25degc: T_25
%   Standard value is at 25degc: RTHx_25
%   RTHx is the thermistor resistance at various temperature
% RTH(t) = RTH(T_25degc) / exp (Beta * (T-T_25)/(T*T_25)))
T_25 = 298.15;
T_off = 273.15;
Beta1 = x(6);
Beta2 = x(8);
RTH1 = x(5) ./ exp(Beta1 * ((Tdata+T_off)-T_25)./((Tdata+T_off)*T_25));
RTH2 = x(7) ./ exp(Beta2 * ((Tdata+T_off)-T_25)./((Tdata+T_off)*T_25));

%% Define equivalent circuits for parallel R's and RTH's
R1_eq = x(1)*RTH1./(x(1)+RTH1);
R3_eq = x(3)*RTH2./(x(3)+RTH2);

%% Calculate voltages at Point B
F = Vin * (R3_eq + x(4))./(R1_eq + x(2) + R3_eq + x(4));```

Contact us