Code covered by the BSD License

# Numerical Computing with Simulink, Vol. 1

08 Sep 2007 (Updated 19 May 2009)

This sequel to Numerical Computing with MATLAB explores the mathematics of simulation.

Train_Data.m
```% Script file with all data needed to simulate a Train system
num_of_people   = 50;                            % Max number of people per car is ???
cars            = 10;                            % Max number of cars is 10
Weight_of_train = cars*(60000+180*num_of_people);
Accel_Constant  = Weight_of_train/32.2*(4.4/3);  % Pounds of force/mph/s

% Dynamic Model Data

V0			    = 30;			 % Initial Train Velocity (mph)
R0				= .3167;		 % Equivalent Series Resistance for Motor

% Tunnel =1 when train is in free air & =2 when it is in a tunnel.

Area            = 100;            % Cross Sectional Area of Tunnel (sq.ft.)
Tunnel          = 1;

%  Drag model: drag(in pounds) = a + bv + cv^2

Constant_drag   = Weight_of_train/2000*1.3+116*cars;     % a
Lin_Drag_force  = Weight_of_train/2000*0.045;            % b

% Data for Train
ArmRes     = .02134*cars;
ArmInd     = .001*cars;
FieldInd   = .001*cars;
ForceConst = 16.5;
VConst     = 4.14;
TotalMass  = Weight_of_train/32.2;

% Distances to Sources (feet)

Pos1 = 42543;            % Location of Substation 1
Pos2 = Pos1 + 5000;      % Location of Substation 2
Pos3 = Pos2 + 8000;      % Location of Substation 3
Pos4 = Pos3 + 5000;      % Location of Substation 4

% Rail Resistances

Rtraction = 2e-6;
Rpower    = 8.7e-6;

% Rail Inductances

Lwctrain1 = Pos1*2e-6;
Lwttrain1 = Pos1*8.7e-6/2;

% Supply Voltage and Resistance

Esupply   =  1050;
Rsupply   =  .012;```