Documentation

Introduction

Support files for use with the https://github.com/kevinanewman/ALPHA_REVS3 and https://github.com/USEPA/EPA_ALPHA_Model GitHub repositories.

Installation

Add folders and subfolders to the Matlab path.

Documentation

The published documentation homepage is https://nvfel-matlab-tools.readthedocs.io/en/latest/

The latest .pdf docs are available at https://nvfel-matlab-tools.readthedocs.io/_/downloads/en/latest/pdf/

Contact Information

NVFEL Matlab Tools Technical Issues

Kevin Newman
United States Environmental Protection Agency
National Vehicle Fuel Emissions Laboratory (NVFEL)
2565 Plymouth Road
Ann Arbor, Michigan 48105
Tel 734-214-4818
Paul DeKraker
United States Environmental Protection Agency
National Vehicle Fuel Emissions Laboratory (NVFEL)
2565 Plymouth Road
Ann Arbor, Michigan 48105
Tel 734-214-4634

NVFEL Matlab Tools Rulemaking Usage

Jeff Cherry
United States Environmental Protection Agency
National Vehicle Fuel Emissions Laboratory (NVFEL)
2000 Traverwood Drive
Ann Arbor, Michigan 48105
Tel 734-214-4371

Agency Information

_images/epa_logo.jpg
United States Environmental Protection Agency
National Vehicle Fuel Emissions Laboratory (NVFEL)
2565 Plymouth Road
Ann Arbor, Michigan 48105
Tel 734-214-4200

Matlab Code

class datatypes.class_accessory_data

class_accessory_data

Universal data structure for accessory load data

Property Summary
DCDC_input_A

DC-DC converter input current in Amps

DCDC_input_V

DC-DC converter input voltage in Volts

DCDC_input_kW

DC-DC converter input power in kiloWatts

DCDC_output_A

DC-DC converter output current in Amps

DCDC_output_V

DC-DC converter outtput voltage in Volts

DCDC_output_kW

DC-DC converter output power in kiloWatts

alternator_A

alternator current in Amps

alternator_V

alternator voltage in Volts

alternator_electrical_kW

alternator electrical power in kiloWatts

alternator_mechanical_kW

alternator mechanical power in kiloWatts

alternator_speed_radps

alternator speed in radians / sec

alternator_torque_Nm

alternator torque in Newton-meters

battery

holds starter/accessory battery data

mechanical_hp

mechanical accessory power in horsepower

mechanical_kW

mechanical accessory power in kiloWatts

speed_radps

mechanical accessory speed in radians / sec

speed_rpm

mechanical accessory speed in RPM

time

data set time in seconds

torque_Nm

mechanical accessory torque in Nm

torque_ftlbs

mechanical accessory torque in foot-pounds

Method Summary
DCDC_input_A_filt(cutoff_Hz, varargin)

DCDC_input_A_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of DCDC_input_A

DCDC_input_V_filt(cutoff_Hz, varargin)

DCDC_input_V_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of DCDC_input_V

DCDC_input_kW_filt(cutoff_Hz, varargin)

DCDC_input_kW_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of DCDC_input_kW

DCDC_output_A_filt(cutoff_Hz, varargin)

DCDC_output_A_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of DCDC_output_A

DCDC_output_V_filt(cutoff_Hz, varargin)

DCDC_output_V_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of DCDC_output_V

DCDC_output_kW_filt(cutoff_Hz, varargin)

DCDC_output_kW_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of DCDC_output_kW

alternator_A_filt(cutoff_Hz, varargin)

alternator_A_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of alternator_A

alternator_V_filt(cutoff_Hz, varargin)

alternator_V_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of alternator_V

alternator_electrical_kW_filt(cutoff_Hz, varargin)

alternator_electrical_kW_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of alternator_electrical_kW

alternator_mechanical_kW_filt(cutoff_Hz, varargin)

alternator_mechanical_kW_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of alternator_mechanical_kW

alternator_speed_radps_filt(cutoff_Hz, varargin)

alternator_speed_radps_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of alternator_speed_radps

alternator_torque_Nm_filt(cutoff_Hz, varargin)

alternator_torque_Nm_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of alternator_torque_Nm

mechanical_hp_filt(cutoff_Hz, varargin)

mechanical_hp_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of mechanical_hp

mechanical_kW_filt(cutoff_Hz, varargin)

mechanical_kW_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of mechanical_kW

speed_radps_filt(cutoff_Hz, varargin)

speed_radps_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of speed_radps

speed_rpm_filt(cutoff_Hz, varargin)

speed_rpm_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of speed_rpm

torque_Nm_filt(cutoff_Hz, varargin)

torque_Nm_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of torque_Nm

torque_ftlbs_filt(cutoff_Hz, varargin)

torque_ftlbs_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of torque_ftlbs

class datatypes.class_battery_data

class_battery_data

Universal data structure for battery data

Property Summary
state_of_charge_norm

battery state of charge, 0..1

terminal_coulombs_Ah

battery terminal Amp-hours

terminal_current_A

battery terminal current in Amps

terminal_energy_Wh

battery terminal energy in Watt-hours

terminal_energy_kWh

battery terminal energy in kiloWatt-hours

terminal_power_kW

battery terminal power in kiloWatts

terminal_voltage_V

battery terminal voltage in Volts

time

data set time in seconds

Method Summary
state_of_charge_norm_filt(cutoff_Hz, varargin)

state_of_charge_norm_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of state_of_charge_norm

terminal_current_A_filt(cutoff_Hz, varargin)

terminal_current_A_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of terminal_current_A

terminal_power_kW_filt(cutoff_Hz, varargin)

terminal_power_kW_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of terminal_power_kW

terminal_voltage_V_filt(cutoff_Hz, varargin)

terminal_voltage_V_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of terminal_voltage_V

class datatypes.class_transmission_data

class_transmission_data

Universal data structure for transmission data

Property Summary
commanded_CVT_ratio

commanded CVT ratio

commanded_gear_number

commanded gear number

commanded_gear_ratio

commanded gear ratio

current_CVT_ratio

current CVT ratio

current_gear_number

current / last gear number

current_gear_ratio

current / last gear ratio

desired_slip_speed_radps

launch device desired slip speed in radians/sec

gear_ratios

vector of forward gear ratios 1..MAX_GEAR

gearbox_input_speed_radps

post-launch-device gearbox input speed in radians/sec

gearbox_input_speed_rpm

gearbox input speed in RPM

gearbox_input_torque_Nm

post-launch-device gearbox input torque in Newton-meters

gearbox_input_torque_ftlbs

post-launch-device gearbox input torque in foot-pounds

gearbox_output_speed_radps

gearbox output speed in radians/sec

gearbox_output_speed_rpm

gearbox output speed in RPM

input_speed_radps

transmission (pre-laumch-device) input speed in radians/sec

input_speed_rpm

transmission input speed in RPM

launch_device_lockup_norm

= 1 if launch device is considered locked, 0 = unlocked

line_pressure_bar

transmission line pressure in bar

line_pressure_psi

transmission line pressure in psi

oil_temp_degC

engine oil temperature in Celsius

oil_temp_degF

engine oil temperature in Fahrenheit

output_torque_Nm

transmission output torque in Newton-meters

output_torque_ftlbs

transmission output torque in foot-pounds

slip_speed_radps

launch device slip speed in radians/sec

slip_speed_rpm

launch device slip speed in RPM

time

data set time in seconds

type

transmission type

Method Summary
commanded_CVT_ratio_filt(cutoff_Hz, varargin)

commanded_CVT_ratio_filt( cutoff_Hz, varargin ) returns lowpass_filter() of commanded_CVT_ratio

commanded_gear_number_filt(cutoff_Hz, varargin)

commanded_gear_number_filt( cutoff_Hz, varargin ) returns lowpass_filter() of commanded_gear_number

commanded_gear_ratio_filt(cutoff_Hz, varargin)

commanded_gear_ratio_filt( cutoff_Hz, varargin ) returns lowpass_filter() of commanded_gear_ratio

current_CVT_ratio_filt(cutoff_Hz, varargin)

current_CVT_ratio_filt( cutoff_Hz, varargin ) returns lowpass_filter() of current_CVT_ratio

current_gear_number_filt(cutoff_Hz, varargin)

current_gear_number_filt( cutoff_Hz, varargin ) returns lowpass_filter() of current_gear_number

current_gear_ratio_filt(cutoff_Hz, varargin)

current_gear_ratio_filt( cutoff_Hz, varargin ) returns lowpass_filter() of current_gear_ratio

gearbox_input_speed_rpm_filt(cutoff_Hz, varargin)

gearbox_input_speed_rpm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of gearbox_input_speed_rpm

gearbox_input_torque_Nm_filt(cutoff_Hz, varargin)

output_torque_Nm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of output_torque_Nm

gearbox_input_torque_ftlbs_filt(cutoff_Hz, varargin)

output_torque_ftlbs_filt( cutoff_Hz, varargin ) returns lowpass_filter() of output_torque_ftlbs

gearbox_output_speed_radps_filt(cutoff_Hz, varargin)

gearbox_output_speed_radps_filt( cutoff_Hz, varargin ) returns lowpass_filter() of gearbox_output_speed_radps

gearbox_output_speed_rpm_filt(cutoff_Hz, varargin)

gearbox_output_speed_rpm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of gearbox_output_speed_rpm

input_speed_radps_filt(cutoff_Hz, varargin)

input_speed_radps_filt( cutoff_Hz, varargin ) returns lowpass_filter() of input_speed_radps

input_speed_rpm_filt(cutoff_Hz, varargin)

input_speed_rpm_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of input_speed_rpm

oil_temp_degC_filt(cutoff_Hz, varargin)

oil_temp_degC_filt( cutoff_Hz, varargin ) returns lowpass_filter() of oil_temp_degC

oil_temp_degF_filt(cutoff_Hz, varargin)

oil_temp_degF_filt( cutoff_Hz, varargin ) returns lowpass_filter() of oil_temp_degF

output_torque_Nm_filt(cutoff_Hz, varargin)

output_torque_Nm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of output_torque_Nm

output_torque_ftlbs_filt(cutoff_Hz, varargin)

output_torque_ftlbs_filt( cutoff_Hz, varargin ) returns lowpass_filter() of output_torque_ftlbs

slip_speed_radps_filt(cutoff_Hz, varargin)

slip_speed_radps_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of slip_speed_radps

slip_speed_rpm_filt(cutoff_Hz, varargin)

slip_speed_rpm_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of slip_speed_rpm

class datatypes.enum_transmission_type

enum_transmission_type

Defines an enumeration of transmission types for use with ALPHA

class datatypes.class_test_data(time_vector)

class_test_data

Top-level universal data structure for automotive test data or simulation data (vehicle, engine, transmission, etc)

Property Summary
MG1

for electric machines (motors/generators)

MG2

for electric machines (motors/generators)

accessory

accessory data

controls

for electric machines (motors/generators)

emachine

for electric machines (motors/generators)

engine

engine data

propulsion_battery

propulsion battery for EVs or HEVs

time

data set time in seconds

transmission

transmission data

vehicle

vehicle data

class datatypes.class_data_column(header_cell_str, format_str, eval_str, verbose)

class_data_column

Used to define columns of data in output files such as .csv files

See also

write_column_row

Property Summary
eval_str

string to be evaluated and printed in output file

format_str

printf format string

header_cell_str

cell array of header data, one row in output file per entry

verbose

verbosity level, 0 = always output, higher numbers control output level as in REVS.verbose

class datatypes.class_vehicle_data

class_vehicle_data

Universal data structure for vehicle data

Property Summary
DS_halfshaft_torque_Nm

driver-side halfshaft torque in Newton-meters

PRNDL

PRNDL position

PS_halfshaft_torque_Nm

passenger-side halfshaft torque in Newton-meters

accel_pedal_bool

‘gas’/accelerator pedal pedal on/off (on = true)

accel_pedal_norm

‘gas’/accelerator pedal position, 0..1

accel_pedal_pct

‘gas’/accelerator pedal position in percent

aerodynamic_drag_coeff

aerodynamic coefficient of drag

brake_pedal_bool

brake pedal on/off (on = true)

brake_pedal_norm

brake pedal position, 0..1

brake_pedal_pct

brake pedal position in percent

coastdown_adjust_A_N

coastdown adjust A/F0 term in Newtons

coastdown_adjust_B_Npms

coastdown adjust B/F1 term in Newtons per meter / second

coastdown_adjust_C_Npms2

coastdown adjust C/F2 term in Newtons per (meter / second)^2

coastdown_target_A_N

coastdown target A/F0 term in Newtons

coastdown_target_B_Npms

coastdown target B/F1 term in Newtons per meter / second

coastdown_target_C_Npms2

coastdown target C/F2 term in Newtons per (meter / second)^2

distance_km

vehicle distance travelled in kilometers

distance_m

vehicle distance travelled in meters

distance_mi

vehicle distance travelled in miles

drive_cycle_phase

target drive cycle phase / “bag”

drive_cycle_speed_mph

target drive cycle speed in miles / hour

drive_cycle_speed_mps

target drive cycle speed in meters / sec

drive_cycle_time

target drive cycle time in seconds

dyno_distance_m

dyno distance in meters

dyno_distance_mi

dyno distance travelled in miles

dyno_load_cell_N

dyno load cell force in Newtons

dyno_load_cell_lbf

dyno load cell force in pounds (force)

dyno_speed_mph

dyno speed in miles / hour

dyno_speed_mps

dyno speed in meters / sec

dyno_tractive_force_N

dyno tractive force in Newtons

dyno_tractive_force_lbf

dyno tractive force in pounds (force)

final_drive_ratio

final drive ratio

frontal_area_m2

vehicle frontal area

fuel

vehicle fuel data

fuel_economy_mpg

fuel economy in miles per gallon

grade_pct

vehicle grade in percent

halfshaft_power_kW

halfshaft power in kiloWatts

halfshaft_torque_Nm

halfshaft torque in Newton-meters

mass_curb_kg

aka curb “weight” in kilograms

mass_dynamic_kg

static mass plus equivalent inertia mass in kilograms

mass_glider_kg

mass of rolling chassis, no driveline, in kilograms

mass_gvw_kg

aka gross vehicle “weight” in kilograms

mass_static_kg

ETW or static mass in kilograms

rolling_resistance_coeff

tire rolling resistance coefficient

speed_kmh

vehicle speed in kilometers/hour

speed_mph

vehicle speed in miles/hour

speed_mps

vehicle speed in meters / sec

time

data set time in seconds

tire_rolling_radius_m

tire rolling radius in meters

wheel_power_kW

power at the wheels in kiloWatts

wheel_speed_radps

wheel speed in radians/sec

wheel_speed_rpm

wheel speed in RPM

wheel_torque_Nm

torque at the wheels in Newton-meters

Method Summary
DS_halfshaft_torque_Nm_filt(cutoff_Hz, varargin)

DS_halfshaft_torque_Nm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of DS_halfshaft_torque_Nm

PS_halfshaft_torque_Nm_filt(cutoff_Hz, varargin)

PS_halfshaft_torque_Nm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of PS_halfshaft_torque_Nm

accel_pedal_bool_filt(cutoff_Hz, varargin)

accel_pedal_bool_filt( cutoff_Hz, varargin ) returns lowpass_filter() of accel_pedal_bool

accel_pedal_norm_filt(cutoff_Hz, varargin)

accel_pedal_norm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of accel_pedal_norm

accel_pedal_pct_filt(cutoff_Hz, varargin)

accel_pedal_pct_filt( cutoff_Hz, varargin ) returns lowpass_filter() of accel_pedal_pct

brake_pedal_bool_filt(cutoff_Hz, varargin)

brake_pedal_bool_filt( cutoff_Hz, varargin ) returns lowpass_filter() of brake_pedal_bool

brake_pedal_norm_filt(cutoff_Hz, varargin)

brake_pedal_norm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of brake_pedal_norm

brake_pedal_pct_filt(cutoff_Hz, varargin)

brake_pedal_pct_filt( cutoff_Hz, varargin ) returns lowpass_filter() of brake_pedal_pct

distance_km_filt(cutoff_Hz, varargin)

distance_km_filt( cutoff_Hz, varargin ) returns lowpass_filter() of distance_km

distance_m_filt(cutoff_Hz, varargin)

distance_m_filt( cutoff_Hz, varargin ) returns lowpass_filter() of distance_m

distance_mi_filt(cutoff_Hz, varargin)

distance_mi_filt( cutoff_Hz, varargin ) returns lowpass_filter() of distance_mi

grade_pct_filt(cutoff_Hz, varargin)

grade_pct_filt( cutoff_Hz, varargin ) returns lowpass_filter() of grade_pct

halfshaft_power_kW_filt(cutoff_Hz, varargin)

halfshaft_power_kW_filt( cutoff_Hz, varargin ) returns lowpass_filter() of halfshaft_power_kW

halfshaft_torque_Nm_filt(cutoff_Hz, varargin)

halfshaft_torque_Nm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of halfshaft_torque_Nm

speed_kmh_filt(cutoff_Hz, varargin)

speed_kmh_filt( cutoff_Hz, varargin ) returns lowpass_filter() of speed_kmh

speed_mph_filt(cutoff_Hz, varargin)

speed_mph_filt( cutoff_Hz, varargin ) returns lowpass_filter() of speed_mph

speed_mps_filt(cutoff_Hz, varargin)

speed_mps_filt( cutoff_Hz, varargin ) returns lowpass_filter() of speed_mps

wheel_power_kW_filt(cutoff_Hz, varargin)

wheel_power_kW_filt( cutoff_Hz, varargin ) returns lowpass_filter() of wheel_power_kW

wheel_speed_radps_filt(cutoff_Hz, varargin)

wheel_speed_radps_filt( cutoff_Hz, varargin ) returns lowpass_filter() of wheel_speed_radps

wheel_speed_rpm_filt(cutoff_Hz, varargin)

wheel_speed_rpm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of wheel_speed_rpm

class datatypes.class_fuel_data(fuel, time)

class_fuel_data

Universal data structure for fuel data

Property Summary
density_kgpL_15C

fuel density in kg / L @ 15C

energy_density_BTUplbm

fuel energy density in BTU / lb(mass)

energy_density_MJpkg

fuel energy density in MJ / kg

flow_rate_ccps

fuel flow rate in cubic centimeters / sec

flow_rate_galps

fuel flow rate in gallons / sec

flow_rate_gps

mass fuel flow rate in grams / sec

gCO2pgal

CO2 grams/gallon

mass_g

total fuel flow mass in grams

temp_degC

fuel temperature in degC

temp_degF

fuel temperature in degrees Fahrenheit

time

data set time in seconds

volume_cc

total fuel flow volume in cubic centimeters

volume_gal

total fuel flow volume in gallons

volume_l

total fuel flow volume in liters

Method Summary
flow_rate_ccps_filt(cutoff_Hz, varargin)

flow_rate_ccps_filt( cutoff_Hz, varargin ) returns lowpass_filter() of flow_rate_ccps

flow_rate_galps_filt(cutoff_Hz, varargin)

flow_rate_galps_filt( cutoff_Hz, varargin ) returns lowpass_filter() of flow_rate_galps

flow_rate_gps_filt(cutoff_Hz, varargin)

flow_rate_gps_filt( cutoff_Hz, varargin ) returns lowpass_filter() of flow_rate_gps

temp_degC_filt(cutoff_Hz, varargin)

oil_temp_degF_filt( cutoff_Hz, varargin ) returns lowpass_filter() of oil_temp_degF

temp_degF_filt(cutoff_Hz, varargin)

oil_temp_degF_filt( cutoff_Hz, varargin ) returns lowpass_filter() of oil_temp_degF

volume_cc_filt(cutoff_Hz, varargin)

volume_cc_filt( cutoff_Hz, varargin ) returns lowpass_filter() of volume_cc

volume_gal_filt(cutoff_Hz, varargin)

volume_gal_filt( cutoff_Hz, varargin ) returns lowpass_filter() of volume_gal

class datatypes.class_controls_data

class_controls_data

Universal data structure for controls data

Property Summary
time

data set time in seconds

class datatypes.class_engine_data

class_engine_data

Universal data structure for engine data

Property Summary
accel_radps2

engine acceleration in radians / sec^2

coolant_temp_degC

engine coolant temperature in Celsius

coolant_temp_degF

engine coolant temperature in Fahrenheit

crankshaft_power_hp

engine crankshaft power in horsepower

crankshaft_power_kW

engine crankshaft power in kiloWatts

crankshaft_torque_Nm

engine crankshaft (net) torque in Newton-meters

crankshaft_torque_ftlbs

engine crankshaft (net) torque in foot-pounds

cylinder_deac_norm

Cylinder deactivation active

efficiency_norm

engine fuel efficiency, 0..1

exhaust_cam_phase_deg

exhaust cam measured phasing relative to parked position

fuel

engine fuel data, class_fuel_data type

fuel_injector

engine fuel data, class_fuel_data type

fuel_meter

engine fuel data, class_fuel_data type

gross_power_hp

engine gross power in horsepower

gross_power_kW

engine gross power in kiloWatts

gross_torque_Nm

engine gross torque (crankshaft torque plus accessory loads) in Newton-meters

gross_torque_ftlbs

engine gross torque (crankshaft torque plus accessory loads) in foot-pounds

intake_cam_phase_deg

intake cam measured phasing relative to parked position

load_at_current_speed_norm

engine load at current speed, 0..1

load_at_current_speed_pct

engine load at current speed in percent

oil_temp_degC

engine oil temperature in Celsius

oil_temp_degF

engine oil temperature in Fahrenheit

speed_radps

engine speed in radians / sec

speed_rpm

engine speed in RPM

throttle_norm

engine throttle position, 0..1

throttle_pct

engine throttle position in percent

time

data set time in seconds

Method Summary
accel_radps2_filt(cutoff_Hz, varargin)

accel_radps2_filt( cutoff_Hz, varargin ) returns lowpass_filter() of accel_radps2

coolant_temp_degC_filt(cutoff_Hz, varargin)

coolant_temp_degC_filt( cutoff_Hz, varargin ) returns lowpass_filter() of coolant_temp_degC

coolant_temp_degF_filt(cutoff_Hz, varargin)

coolant_temp_degF_filt( cutoff_Hz, varargin ) returns lowpass_filter() of coolant_temp_degF

crankshaft_power_hp_filt(cutoff_Hz, varargin)

crankshaft_power_hp_filt( cutoff_Hz, varargin ) returns lowpass_filter() of crankshaft_power_hp

crankshaft_power_kW_filt(cutoff_Hz, varargin)

crankshaft_power_kW_filt( cutoff_Hz, varargin ) returns lowpass_filter() of crankshaft_power_kW

crankshaft_torque_Nm_filt(cutoff_Hz, varargin)

crankshaft_torque_Nm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of crankshaft_torque_Nm

crankshaft_torque_ftlbs_filt(cutoff_Hz, varargin)

crankshaft_torque_ftlbs_filt( cutoff_Hz, varargin ) returns lowpass_filter() of crankshaft_torque_ftlbs

efficiency_norm_filt(cutoff_Hz, varargin)

efficiency_norm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of efficiency_norm

gross_power_hp_filt(cutoff_Hz, varargin)

gross_power_hp_filt( cutoff_Hz, varargin ) returns lowpass_filter() of gross_power_hp

gross_power_kW_filt(cutoff_Hz, varargin)

gross_power_kW_filt( cutoff_Hz, varargin ) returns lowpass_filter() of gross_power_kW

gross_torque_Nm_filt(cutoff_Hz, varargin)

gross_torque_Nm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of gross_torque_Nm

gross_torque_ftlbs_filt(cutoff_Hz, varargin)

gross_torque_ftlbs_filt( cutoff_Hz, varargin ) returns lowpass_filter() of gross_torque_ftlbs

load_at_current_speed_norm_filt(cutoff_Hz, varargin)

load_at_current_speed_norm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of load_at_current_speed_norm

load_at_current_speed_pct_filt(cutoff_Hz, varargin)

load_at_current_speed_pct_filt( cutoff_Hz, varargin ) returns lowpass_filter() of load_at_current_speed_pct

oil_temp_degC_filt(cutoff_Hz, varargin)

oil_temp_degC_filt( cutoff_Hz, varargin ) returns lowpass_filter() of oil_temp_degC

oil_temp_degF_filt(cutoff_Hz, varargin)

oil_temp_degF_filt( cutoff_Hz, varargin ) returns lowpass_filter() of oil_temp_degF

speed_radps_filt(cutoff_Hz, varargin)

speed_radps_filt( cutoff_Hz, varargin ) returns lowpass_filter() of speed_radps

speed_rpm_filt(cutoff_Hz, varargin)

speed_rpm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of speed_rpm

throttle_norm_filt(cutoff_Hz, varargin)

throttle_norm_filt( cutoff_Hz, varargin ) returns lowpass_filter() of throttle_norm

throttle_pct_filt(cutoff_Hz, varargin)

throttle_pct_filt( cutoff_Hz, varargin ) returns lowpass_filter() of throttle_pct

class datatypes.unit_convert

UNIT_CONVERT - unit conversion class

Property Summary
BTUplbm2Jpkg

NIST

BTUplbm2MJpkg

by definition

MPa2bar

by definition

MPa2kPa

by definition

bar2Pa

by definition

bar2kPa

by definition

ftlbs2Nm

NIST

g

NIST

gal2cc

by definition

galdies2gCO2

EPA LD GHG rule

galgas2gCO2

EPA LD GHG rule

hp2W

NIST

hp2kW

by definition

in2cm

by definition

in2m

by definition

in2mm

NIST

kW2W

by definition

lbf2N

NIST

lbm2kg

NIST

lit2cc

by definition

lit2gal

NIST

mi2mtr

NIST

mph2kmh

by definition

mps2kmh

by definition

mps2mph

by definition

psi2bar

by definition

psi2kPa

NIST

rpm2radps

by definition

specific_gravity2density_kgpL_60F

by definition

ton2lbm

by definition

water_density_gpgal_60F

nominal 3781.8; % 0.99904 = ASTM D 4052 density of water at 60F, grams per cc

water_density_nominal_gpgal_60F

0.99904 = ASTM D 4052 density of water at 60F, grams per cc, rounded

class datatypes.class_emachine_data

class_emachine_data

Universal data structure for emachine (electric motor/generator) data

Property Summary
current_A

emachine electrical current in Amps

efficiency_norm

emachine efficiency 0..1

electrical_power_kW

battery terminal power in kiloWatts

mechanical_power_kW

output shaft power in kiloWatts

speed_radps

emachine shaft speed in radians/sec

speed_rpm

emachine shaft speed in rpm

time

dataset time in seconds

torque_Nm

emachine shaft torque in Newton-meters

voltage_V

emachine electrical potential in Volts

Method Summary
current_A_filt(cutoff_Hz, varargin)

current_A_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of current_A

efficiency_norm_filt(cutoff_Hz, varargin)

efficiency_norm_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of efficiency_norm

electrical_power_kW_filt(cutoff_Hz, varargin)

electrical_power_kW_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of electrical_power_kW

mechanical_power_kW_filt(cutoff_Hz, varargin)

mechanical_power_kW_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of mechanical_power_kW

speed_radps_filt(cutoff_Hz, varargin)

speed_radps_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of speed_radps

speed_rpm_filt(cutoff_Hz, varargin)

speed_rpm_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of speed_rpm

torque_Nm_filt(cutoff_Hz, varargin)

torque_Nm_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of torque_Nm

voltage_V_filt(cutoff_Hz, varargin)

voltage_V_filt( obj, cutoff_Hz, varargin ) returns lowpass_filter() of voltage_V

functions.calc_roadload_abc_N(A_N, B_N, C_N, MPH, varargin)

[roadload_force_N, roadload_power_kW, roadload_force_lbs, roadload_power_hp] = calc_roadload_abc_N(A_N, B_N, C_N, MPH, varargin)

CALC_ROADLOAD_ABC_N Calculate roadload force and power given roadload coefficients in SI units and a vector of speeds in miles per hour

Parameters:
  • A_N – ‘A’/’F0’ roadload coefficient, SI units

  • B_N – ‘B’/’F1’ roadload coefficient, SI units

  • C_N – ‘C’/’F2’ roadload coefficient, SI units

  • MPH – vector of vehicle speeds at which to calculate rooadload, in miles per hour

  • varargin (optional keyword and name-value arguments) –

    • ‘grade_pct’: road grade in percent

    • ’mass_kg’: vehicle mass in kg, for use with grade_pct

Returns:

Roadload force and power in SI and SAE units at the given vehicle speeds

Example

Calculate roadload horsepower at 50 mph:

[~,~,~, postproc_results.roadload_50mph_hp] =
    calc_roadload_abc_N(vehicle.coastdown_target_A_N, vehicle.coastdown_target_B_Npms, vehicle.coastdown_target_C_Npms2,  50);
functions.regexpcmp(str, expression, varargin)

[match] = REGEXPCMP( str, expression, varargin )

Compare string via regular expression. Similar to strcmp except the comparison utilizes regular expressions.

Parameters:
  • str – string or cell array of strings to compare with expression

  • expression – regular expression or cell array of regular expressions

  • varargin – varargs supported by regexp()

Returns:

Cell array of boolean comparison results

See also: regexp, cellfun, strcmp

functions.fieldnames_all(varname_str, varargin)

[vars, var_containers] = fieldnames_all(varname_str, varargin)

Get names of all fields/subfields of varname_str and a cell array of which fields contain other fields

Parameters:
  • varname_str (str) – name of variable to get fieldnames of

  • varargin (optional keyword and name-value arguments) –

    • ‘sort_fieldnames’:

      sort fieldnames alphabetically

Returns:

string cell array of fieldnames, string cell array of fieldnames that contain futher fieldnames (e.g. structs within structs)

Return type:

tuple

See also: fieldnames

Example:

>> postproc_results

ans =

  struct with fields:

          performance: [1×1 struct]
     weighted_results: [1×1 struct]
    roadload_50mph_hp: 11.4486672205998


>> [vars, var_containers] = fieldnames_all('postproc_results')

vars =

  4×1 cell array

    {'postproc_results.performance.grade_reserve_pct'        }
    {'postproc_results.weighted_results.combined_GHG_gCO2pmi'}
    {'postproc_results.weighted_results.load_factor_norm'    }
    {'postproc_results.roadload_50mph_hp'                    }


var_containers =

  3×1 cell array

    {'postproc_results'                 }
    {'postproc_results.performance'     }
    {'postproc_results.weighted_results'}
functions.sum_fields_regexp(s, expr)

[sum, found] = SUM_FIELDS_REGEXP(s, expr)

Return sum of fieldnames/properties of s that match expr

Parameters:
  • s – object or structure variable to sum fields of

  • expr – regular expression supported by regexp

Returns: sum of fieldname/property vectors of s that match expr

Example:

input_energy_pos = sum_fields_regexp(obj, '^input[0-9]*_pos_kJ$');

See also: regexp

functions.scatter2surf(x, y, z, xq, yq, varargin)

SCATTER2SURF Scattered data interpolation and fitting

Zq = SCATTER2SURF(X,Y,Z,Xq,Yq) converts 3 dimensional scattered data (x, y, z) to a surface on a 2d grid specified by Xq and Yq. Replicates are allowed, but may result in warnings. It allows extrapolation in most cases. Supports interpolation via MATLAB scatteredinterpolant or surface fitting via gridfit algorithm which features tunable smoothness parameters. SCATTER2SURF also generates a variety of plots to help tune parameters and demonstate results.

[Xq, Yq, Zq] = SCATTER2SURF(X,Y,Z, Xq, Yq) is an alternate syntax that allows export of the corresponding mesh grid for additional plotting.

SCATTER2SURF(…, prop, val)can be used to set a variety of properties that control the behavior of the surface generation. Details of the properties are specified below.

Optional Parameters:

method - [‘scatteredinterp’] ‘gridfit’ Selects the method used to generate the surface.

‘scatteredinterp’ uses the matlab scatteredinterpolant or triscatteredinterp functions to generate a delaunay triangulation of the scattered data and interpolate. Since it is an interpolant it should pass through each provided data point, assuming there are no repeats.

‘gridfit’ uses the gridfit algorithm, which is similar to a curve fit Gridfit is not an interpolant. Its goal is a smooth surface that approximates your data, but allows you to control the amount of smoothing. It accomplishes this by connecting the data points to nearby grid points and solving for a least squares solution.

‘greens’

‘interp’ - [‘linear’], ‘triangle’,’nearest’,’natural’,’bilinear’,’bicubic’ Determines the interpolation method used

‘triangle’ or ‘linear’ for the ‘scatterinterp’ method uses the delaunay triangulation to interpolate each grid point via the plane connecting the 3 nearest data points. For ‘gridfit’ it connects each data point with the 3 nearest grid points.

‘nearest’ for the ‘scatteredinterp’ method uses the data point

nearest the grid for the value at that point. For ‘gridfit’ it connects each data point only to the nearest grid point. This will rarely be a good option.

‘natural’ is used only with ‘scatteredinterp’ and performs natural neighbor interpolation that factors in additional nearby points when interpolating.

‘bilinear’ is only used with the ‘gridfit’ method and connects each data point to the 4 nearest grid points. The bilinear interpolation within is also known as tensor product linear interpolation and is similar to the interpolation used for gridded data

‘xscale’ - scalar number ‘xnormalize’ - no argument ‘yscale’ - scalar number ‘ynormalize’ - no argument These inputs provide options for scaling the axes of the data to a common scale. Since interpolation is based on distance if the scale of x and y data is significantly different it may not be interpolated as expected. ‘xscale’ and ‘yscale’ scale the data by the specified amount. ‘xnormalize’and ‘ynormalize’ normalize the data down to the range 0..1

‘xsmooth’ - scalar number - default:1 ‘ysmooth’ - scalar number - default:1 Specify the desired smoothing along each axis and relative to the data. Increasing the smoothness will create a more uniform surface but may deviate from the data. While decreasing the smoothing will match the data better but have a more undulating shape.

‘solver’ - [’'],’symmlq’,’lsqr’,’normal’

Set the solver to be used with the ‘gridfit’ method to solve the linear system. Different solvers will have different solution times depending upon the specific problem to be solved. Up to a certain size grid, the

direct solver will often be speedy, until memory is limited. Problems

with a significant amount of extrapolation should avoid lsqr. may be best numerically for small smoothnesss parameters and high extents of extrapolation.

‘' uses matlab’s backslash operator to solve the sparse system.

‘symmlq’ uses matlab’s iterative symmlq solver

‘lsqr’ uses matlab’s iterative lsqr solver

‘normal’ uses to solve the normal equations.

‘maxiter’ - scalar number - default:min(10000,size of grid) Specified the maximum number of iterations for an iterative solver

‘surf’ - generates a surface plot ‘no_dots’ - disables black dots on surface plot with ‘surf’ option

functions.lowpass_filter(val, time, cutoff_hz, varargin)

[filt_val] = LOWPASS_FILTER(val, time, cutoff_hz, varargin)

Perform a low-pass filter at cutoff_hz of val over time.

Parameters:
  • val (numeric) – value to be filtered

  • time (numeric) – time vector of val

  • cutoff_hz (numeric) – cutoff frequency of low-pass filter in Hz

  • varargin (optional keyword and name-value arguments) –

    • ‘do_plots’: enable plots of raw and filtered value

    • ’time_align_disable’: disable time-alignment of filtered and raw value

Returns:

vector of filtered value

See also

time_aligner

functions.ndgridfit(pts, v, weighting, grid_pts, varargin)

ndGridfit: Produces a smooth surface surface from scattered input data.

NDGridfit is a refactoring of RegularizeData3D and Gridfit, expanding the approach to solve higher dimensional cases. It also adds support for weighting each of the individual input points.

This code incorporates some improvements from RegularizeData3D, specifically the revised smoothing parameters to be more consistient accross different grid sizes. ndGridfit does not currently support the cubic interpolation, but that can hopefully be revised and included in the future.

Gridfit featured multiple regularizer functions, but only the ‘gradient’ option which seeks to minimize the 2nd derivative is included in this version.

A quick summary of the Gridfit method: Gridfit creates a system of equations to solve for a best fit surface corresponding to a scattered dataset. The surface is defined ovar a grid of points, passed as the breakpoints for each dimension. To accomplish its fitting it generates two sets of equations. The first set connects the provided data to the grid. There are various options to make these connections passed via the ‘interp’ argument. The second set of equations are the regularizer. The regularizer is what seeks to contrain the resulting output to a smooth surface. The combined set of equations can be very large but also sparse, and a variety of solvers are avaialble.

There are snippets of Gritfit and RegularizeData3D code remaining, and the overall program flow matches as well.

The original GridFit page is:

http://www.mathworks.com/matlabcentral/fileexchange/8998-surface-fitting-using-gridfit

usage #1: vgrid = ndgridfit(pts, v, weighting, grid_points); usage #2: [vgrid, xgrid, ygrid] = ndgridfit([x, y], z, [], {xnodes, ynodes}); usage #3: vgrid = ndgridfit([x, y, z], v, [], {xnodes, ynodes, znodes}, prop, val, prop, val,…);

Arguments: (input)
pts,v - scattered data on which to fit the surface. Each row in pts

represents a point in the n-dimensional space. the vector v represents the value of data at each point in pts. Replicate points will be treated in a least squares sense and any points containing a NaN are ignored in the estimation.

weighting - vector of length equal to v, containing weightings for

individual data points. This parameter may be omitted (replaced by []) for a equal weighting of all points.

grid_pts - cell array containing the corresponding grid nodes for each

dimension. The number of elements in grid_pts should match the number of columns in pts. The nodes need not be equally spaced. The grid points for each dimension must completely span the data. If they do not, then the ‘extend’property is applied, adjusting the first and last nodes to be extended as necessary. See below for a complete description of the ‘extend’ property.

Additional arguments follow in the form of property/value pairs. Valid properties are:

‘smoothness’, ‘interp’, ‘solver’, ‘maxiter’ ‘extend’, ‘tilesize’, ‘overlap’

Any UNAMBIGUOUS shortening (even down to a single letter) is valid for property names. All properties have default values, chosen (I hope) to give a reasonable result out of the box.

‘smoothness’ - scalar or vector - the ratio of

smoothness to fidelity of the output surface. This must be a positive real number.

A smoothness of 1 gives equal weight to fidelity (goodness of fit) and smoothness of the output surface. This results in noticeable smoothing. If your input data has little or no noise, use 0.01 to give smoothness 1% as much weight as goodness of fit. 0.1 applies a little bit of smoothing to the output surface.

If this parameter is a vector, then it defines the relative smoothing to be associated with the different dimensions. This allows the user to apply a different amount of smoothing in each dimension.

DEFAULT: 0.01

‘interp’ - character, denotes the interpolation scheme used

to interpolate the data.

DEFAULT: ‘triangle’

‘cubic’ - use bicubic interpolation within the grid,more

accurate because it accountsfor surface curvature, but can be slower than the other methods. 4^n equations per data point

‘linear’ - use linear interpolation within the grid, connecting

the two nearest points along each dimension. 2^n equations per data point

‘triangle’ - use only the points encompassing the datapoint for

interpolation. n+1 equations per data point

‘nearest’ - nearest neighbor interpolation. This will

rarely be a good choice, but is included for completeness. 1 equation per data point

‘solver’ - character flag - denotes the solver used for the

resulting linear system. Different solvers will have different solution times depending upon the specific problem to be solved. Up to a certain size grid, the direct solver will often be speedy, until memory swaps causes problems.

What solver should you use? Problems with a significant amount of extrapolation should avoid lsqr. may be best numerically for small smoothnesss parameters and high extents of extrapolation.

Large numbers of points will slow down the direct , but when applied to the normal equations, can be quite fast. Since the equations generated by these methods will tend to be well conditioned, the normal equations are not a bad choice of method to use. Beware when a small smoothing parameter is used, since this will make the equations less well conditioned.

DEFAULT: ‘normal’

‘' - uses matlab’s backslash operator to solve the sparse

system. ‘backslash’ is an alternate name.

‘symmlq’ - uses matlab’s iterative symmlq solver

‘lsqr’ - uses matlab’s iterative lsqr solver

‘normal’ - uses to solve the normal equations.

‘maxiter’ - only applies to iterative solvers - defines the

maximum number of iterations for an iterative solver

DEFAULT: min(10000,length(xnodes)*length(ynodes))

Arguments: (output)

vgrid - n dimensional array containing the fitted hypersurface

Speed considerations:

Remember that gridfit must solve a LARGE system of linear equations. There will be as many unknowns as the total number of nodes in the final lattice. While these equations may be sparse, solving a system of 10000 equations may take a second or so. Very large problems may benefit from the iterative solvers or from tiling.

Example usage:

x = rand(100,1); y = rand(100,1); z = exp(x+2*y); xnodes = 0:.1:1; ynodes = 0:.1:1;

g = RegularizeData3D(x,y,z,xnodes,ynodes);

Note: this is equivalent to the following call:

g = RegularizeData3D(x,y,z,xnodes,ynodes, …

‘smooth’,1, … ‘interp’,’triangle’, … ‘solver’,’normal’, … ‘gradient’, … ‘extend’,’warning’, … ‘tilesize’,inf);

Refactored for n-dimensional support and released as ndgridfit

2021 - Able to solve for adiditional dimensions - Added weighting function for input data points - Tiling functionality omitted for now

Rereleased with improvements as RegularizeData3D

2014 - Added bicubic interpolation - Fixed a bug that caused smoothness to depend on grid fidelity - Removed the “regularizer” setting and documented the calculation process

Original Version:

Author: John D’Errico e-mail address: woodchips@rochester.rr.com Release: 2.0 Release date: 5/23/06

functions.normalize(var, index)

[answer] = NORMALIZE(var, index)

answer = var./var(index);

Parameters:
  • var – vector to normalize

  • index – index of var to normalize by

Returns: var normalized by var(index)

functions.table2columns(mat, varargin)

TABLE2COLUMNS convert lookup table to serialized column data

functions.find_clusters(in, threshold)
if nargin < 2

min_cluster_size = 1;

end

functions.CFR_city_highway_weighted_combined(city, highway, varargin)

[answer] = CFR_city_highway_weighted_combined( city, highway, varargin )

CFR_CITY_HIGHWAY_WEIGHTED_COMBINED calculates a weighted combined result from city/highway quantities (gallons / grams / energy) per (mi / m / km) or (mi / m /km) per quantity (gallons / grams / energy), depending on the varargs, weighted 55% “city” and 45% “highway”, as for EPA emissions test results

Parameters:
  • city (numeric) – “city” value to be weighted 55%

  • highway (numeric) – “highway” value to be weighted 45%

  • varargin (optional keyword and name-value arguments) –

    • ‘dist_per_quant’:

      indicates values are distance per quantity, as in miles per gallon

    • ’quant_per_dist’:

      indicates values are in quantity per distance, as in grams per mile

Returns:

Value weighted 55% city, 45% highway

functions.export2struct(varargin)

[s] = EXPORT2STRUCT(varargin)

Save some or all of a Matlab workspace in a structure object.

Parameters:

varargin (optional keyword and name-value arguments) –

  • ‘clear’:

    clear variables from workspace after export

  • ’select’ (cell array of strings):

    names of variables to export, used to limit export to a subset of all variables

  • ’exclude’ (cell array of strings):

    names of variables to exclude from export, used to limit export to a subset of all variables

Returns:

Workspace variables within a structure object as fieldnames

functions.REVS_fullfact(opts)

[out] = REVS_fullfact(opts)

Full-factorial matrix generator

Creates a design matrix OUT containing the settings for a full factorial. The input vector opts specifies the number of options for each level in the design.

Parameters:

opts – Vector of factorial dimensions

Returns:

Full factorial matrix with levels defined by opts

Example:

>> REVS_fullfact([1,2,3])

   ans =

        1     1     1
        1     2     1
        1     1     2
        1     2     2
        1     1     3
        1     2     3
functions.was_provided(var)

[ answer ] = was_provided( var ) Used in data classes to see if property was ever provided by the user. Returns true if var is not empty and has non-NaN values

Parameters:

var – variable to test for non-empty, non-NaN values

Returns:

true if var is non-empty and has non-NaN values

functions.delta(vector, mode)

[answer] = DELTA(vector, mode)

Approximate derivative with length(vector) elements.

Returns diff(vector), prepended with either the first element of diff(vector) if mode == 1, or 0 if mode == 2.

Parameters:
  • vector – variable to create approximate derivative of

  • mode – first element of result is first element of diff(vector) if mode == 1, first element is 0 otherwise

Returns: diff(vector), prepended with either the first element of diff(vector) if mode == 1, or 0 if mode == 2.

See also: diff

functions.validate_arg(arg_in, arg_type, arg_attrib)

[ value ] = validate_arg( arg_in, arg_type, arg_attrib )

Validate arg_in against arg_type and arg_attrib. Extends behavior of Matlab as in validateattributes, validatestring

Parameters:
  • arg_in – variable to be validated

  • arg_type

    type to be validated against:
    • ’cellstr’: cell array of strings

    • ’file’: file identifier or file name

    • ’dir’: directory identifier or directory name

    • ’colormap’: matlab colormap

    • ’char’: char or string

    • ’logical’: logical value type

    • arbitrary matlab type

  • arg_attrib – attributes as in validateattributes / validatestring attributes parameter

See also

validateattributes, validatestring

functions.CFR_FTP_harmonic_average(bag_quantities, bag_distances, mode)

[dist_per_quant, quant_per_dist] = CFR_FTP_HARMONIC_AVERAGE(bag123_distances, bag123_quantities)

CFR_FTP_HARMONIC_AVERAGE calculates a weighted FTP result

bag1..3 quantities (gallons / grams / energy) and distances weighted 43% “cold” (bags 1&2) and 57% “hot” (bags 3&2) as per CFR 86.144-94, https://www.ecfr.gov/cgi-bin/retrieveECFR?gp=&n=sp40.21.86.b&r=SUBPART&ty=HTML#se40.21.86_1144_694

bag1..4 quantities (gallons / grams / energy) and distances weighted 43% “cold” (bags 1&2) and 57% “hot” (bags 3&4) as per 40 CFR § 1066.820, https://www.ecfr.gov/cgi-bin/text-idx?node=pt40.37.1066&rgn=div5#se40.37.1066_1820

Parameters:
  • bag_distances – vector of distances (as in miles)

  • bag_quantities – vector of quantities (as in grams or gallons)

  • mode – calculation mode ‘qpd’: quantity per distance ‘dpq’: distance per quantity ‘avg’: weighted average

Returns:

value weighted per CFR calculation

functions.CFR_FTP_4bag_harmonic_average(bag1234_distances, bag1234_quantities)

[dist_per_quant, quant_per_dist] = CFR_FTP_HARMONIC_AVERAGE(bag123_distances, bag123_quantities)

CFR_FTP_HARMONIC_AVERAGE calculates a weighted FTP result from bag1..4 quantities (gallons / grams / energy) and distances weighted 43% “cold” (bags 1&2) and 57% “hot” (bags 3&4) as per 40 CFR § 1066.820, https://www.ecfr.gov/cgi-bin/text-idx?node=pt40.37.1066&rgn=div5#se40.37.1066_1820

Parameters:
  • bag1234_distances – vector of “bag” 1,2,3,4 distances (as in miles)

  • bag1234_quantities – vector of “bag” 1,2,3,4 quantities (as in grams or gallons)

Returns:

harmonic average distance per quantity (as in miles per gallon), harmonic average quantity per distance (as in grams per mile)

Return type:

tuple

functions.hash(in)

Get a bytestream from the input. Note that this calls saveobj.

functions.parse_varargs(varargs, name, default, varargin)

[value] = PARSE_VARARGS(varargs, name, default, class, attributes )

Search varargs for name, checks the following value for type class and attributes. The class and attributes arguments are optional. Arguments not matching the class and/or attributes provided will return an error. For a list of available attributes used with numeric data types consult the MATLAB validateattributes function documentation. If the requested class is ‘char’ then the attributes argument can be used to specify a list available strings. An entry not matching one of the provided string will generate an error.

Parameters:
  • varargs – cell array of names/name-value pairs, varargin from calling function

  • name – string name of varargin to parse

  • default – default value for value if name not found

  • varargin (optional keyword and name-value arguments) –

    • ‘toggle’, or validation / vararg type information supported by

      validate_arg() and validateattributes()

Returns:

Default value or value provided by varargs

See also: validate_arg, validateattributes, validatestring

Hint

‘toggle’ type varargs have a default boolean value and providing the named vararg string toggles the value from true to false or vice versa

functions.REVS_SAEJ2951(data, varargin)

[drive_quality_stats] = REVS_SAEJ2951( data, varargin )

Calculate drive cycle metrics as in SAEJ2951, https://www.sae.org/standards/content/j2951_201111/

Parameters:
  • data (typically a class_test_data object) – drive cycle data to calculate SAEJ2951 drive metrics for

  • varargin (optional keyword and name-value arguments) –

    • ‘do_plots’: enable plot of target and actual vehicle speeds

    • ’verbose’, numeric:

      enable console / file output of results if non-zero

    • ’output_fid’, numeric:

      output file identifier, defaults to “1”, the console

    • ’use_unadjusted_ABCs’:

      use target ABC coastdown coefficients, not adjusted coefficients

Returns:

Structure of drive cycle metrics as in SAEJ2951

Tip

data is not required to be of class_test_data type but must contain the following fieldnames / properties:

  • vehicle.coastdown_target_A_N

  • vehicle.coastdown_adjust_A_N

  • vehicle.coastdown_target_B_Npms

  • vehicle.coastdown_adjust_B_Npms

  • vehicle.coastdown_target_C_Npms2

  • vehicle.coastdown_adjust_C_Npms2

  • vehicle.mass_static_kg (ETW)

  • vehicle.drive_cycle_phase

  • time

  • vehicle.speed_mps

  • vehicle.drive_cycle_speed_mps

Example console output:

SAE J2951 Drive Quality Metrics:
Time secs         510.000000
CEt MJ            2.840796
CEt_dist J/m      491.558031
CEd MJ            2.834872
CEd_dist J/m      490.429212
ER %             -0.21
DR %             0.02
EER %            -0.23
ASCt              0.204903
ASCd              0.205609
ASCR %           0.34
Dt mi             3.591008
Dt m              5779.167465
Dd mi             3.591768
Dd m              5780.390388
Distance Error mi -0.000760
RMSSE_mph         0.104691

See also

class_REVS_test_data, calc_roadload_adjust

functions.time_aligner(reference_time, reference_data, comparison_time, comparison_data, varargin)

[best_offset_time, offset_time, comparison_error] = time_aligner( reference_time, reference_data, comparison_time, comparison_data, varargin )

Find the time offset that best time-aligns comparison data with reference data.

Note

Comparison timespan needs to be longer than reference timespan. If the reference and the comparison data have the same timespan, use the ‘reference_xxx’ varargins to shorten the reference timespan.

Parameters:
  • reference_time (numeric) – time vector of reference_data

  • reference_data (numeric) – reference data to time-align comparison_data with

  • comparison_time (numeric) – time vector of comparison_data

  • comparison_data (numeric) – data to time-align to reference_data

  • varargin (optional keyword and name-value arguments) –

    • ‘reference_window’, numeric

      2-element vector to define the start and end times of the reference window, format [start_time, end_time], by default the entire reference_time timespan is used unless overridden

    • ’reference_start’, numeric

      define reference window start time

    • ’reference_end’, numeric

      define reference window end time

    • ’comparison_window’, numeric

      2-element vector to define the start and end times of the comparison window, format [start_time, end_time], by default the entire comparison_time timespan is used unless overridden

    • ’comparison_start’, numeric

      define comparison window start time

    • ’comparison_end’, numeric

      define comparison window end time

    • ’offset_interval’, numeric

      time alignment accuracy, default is the lesser of 0.1 and one-fifth of the median of comparison_time delta-t

  • Returns – tuple: best offset time (to be added to comparison_time to perform alignment), offset times and comparison errors at those times

functions.REVS_regress(y, X)

REVS_REGRESS Multiple linear regression using least squares, similar to the core of the MATLAB regress function.

Returns the vector B of regression coefficients in the linear model y = X*B. X is an n-by-p design matrix, with rows corresponding to observations and columns to predictor variables. y is an n-by-1 vector of response observations.

Parameters:
  • y – left hand side, variable to provide regression for

  • X – right hand side, matrix

Returns:

Returns the vector B of regression coefficients in the linear model y = X*B

Note

Number of rows in X and y must match

graphics.sax

SAX - set plot x-axis

Sets plot x-axis min and max values based on the workspace variables gax1 and gax2 respectively

Typically used with gax

See also

axis, gax, gay, say, gaxy, saxy, saxall, gaz, saz

graphics.superplot(varargin)

[h] = SUPERPLOT(varargin) SUPERPLOT upgraded linear plotting compatible with Matlab plot function

SUPERPLOT is a replacement for the built-in matlab plotting with additional options and functionaliy. Default colors based on SAE guidelines for technical papers

Parameters:

varargin (optional keyword and name-value arguments) – plot arguments

Returns:

vector of line series handles

Return type:

line series handle

SUPERPLOT(Y) and SUPERPLOT(X,Y) behaves similar to plot(Y) and plot(X,Y) except that the defualt line width is 2 for easier readability

SUPERPLOT(X,Y,S) accepts line and marker style properties like plot, but has additional colors and features available. Whereas the line specification for plot only contains color, marker and line style SUPERPLOT can take arguments composed of the following parameters, all of which are optional:

marker edge color - see color list below
marker face color - see color list below
marker shape - see list below
marker size - default value = 6
line color - see color list below
line style - see list below
line width - default value = 2

SUPERPLOT(X1,Y1,S1,X2,Y2,S2,…) allows multiple lines to be plotted just as with plot

Examples: Light blue circle markers of size 7 with a black dashed line of size 3:

superplot(X,Y,'lbo7k--3');

Red square markers with yellow centers connected by a blue solid line:

superplot(X,Y,'rysb-');

Note if only one color is supplied it will be used for all marker and line elements

 Color Codes
         lb              light blue              matches SAE Blue
         b               medium blue*
         db              dark blue               matches SAE Dark Blue
         lg              light green             matches SAE Light Green
         g               green*                  matches SAE Dark Green
         dg              dark green
         y               yellow*                 matches SAE Yellow
         r               red*                    matches SAE Red
         lr              light red
         dr              dark red
         gy              gray                    matches SAE Medium Gray
         or              orange                  matches SAE Orange
         m               magenta
         w               white
         c               cyan
         k               black
         vt              violet / purple
         pu              violet / purple
         * denotes codes shared matlab plot using different color values

 Markers Types                           Line Styles
.     point                                        -     solid
o     circle                               :     dotted
x     x-mark                               -.    dashdot
+     plus                                         --    dashed
         *     star                                      (none)  no line
         s     square
d     diamond
v     triangle (down)
^     triangle (up)
<     triangle (left)
>     triangle (right)
p     pentagram
h     hexagram
graphics.sayall

SAYALL - set plot y-axis for all active plots

Sets plot y-axis min and max values based on the workspace variables gay1 and gay2 respectively, for all active plots

Typically used with gay

See also

axis, gax, gay, say, gaxy, saxy, saxall, gaz, saz

graphics.gax

GAX - grab plot x-axis

Sets workspace variables gax1 and gax2 with the min and max x-axis values, respectively, of the current plot

Typically used with sax

See also

axis, sax, gay, say, gaxy, saxy, saxall

graphics.fplot(varargin)
[lineseries] = FPLOT(varargin)

Shortcut for: figure; plot;

Parameters:

varargin (optional keyword and name-value arguments) – plot arguments

Uses superplot instead of Matlab plot, but essentially the same. If no active figure exists, it is created.

Returns:

handle to line series

Return type:

line series handle

Example

Create a simple plot with two lines, hold and grid on. First line red, second line blue:

figure;
plothg([1 2 3], [4 5 6], 'r-');
plothg([0 1 2], [6 5 4], 'b-');

See also

figure, plot, superplot

graphics.xyzt(plot_x_label, plot_y_label, plot_z_label, varargin)
XYT(plot_x_label, plot_y_label, varargin)

Set plot x- and y- and z-labels, optionally set the plot title.

Shortcut for setting plot labels using xlabel, ylabel, zlabel and optionally title

Parameters:
  • plot_x_label (str) – plot x-axis label string

  • plot_y_label (str) – plot y-axis label string

  • plot_z_label (str) – plot z-axis label string

  • varargin (optional keyword and name-value arguments) –

    • first positional vararg (string)

      plot title string

    • subsequent varargs

      passed to title function

    • ’no_date’

      disable automatic date string in title

Examples

Set x-, y- and z-axis labels:

xyzt('Engine Speed (RPM)', 'Engine Torque (Nm)', 'Engine Efficiency (%)');

Set x-, y- and z-axis labels, omitting automatic date reference:

xyzt('Engine Speed (RPM)', 'Engine Torque (Nm)', 'Engine Efficiency (%)', 'no_date');

Set x-, y- and z-axis labels and title:

xyzt('Engine Speed (RPM)', 'Engine Torque (Nm)', 'Engine Efficiency (%)', 'Engine Efficiency Plot');

Note

Sets label and title Interpreters to ‘none’, so underscores display properly

See also

xlabel, ylabel, title, xyt

graphics.xyt(plot_x_label, plot_y_label, varargin)
XYT(plot_x_label, plot_y_label, varargin)

Set plot x- and y-labels, optionally set the plot title.

Shortcut for setting plot labels using xlabel and ylabel, and optionally title

Parameters:
  • plot_x_label (str) – plot x-axis label string

  • plot_y_label (str) – plot y-axis label string

  • varargin (optional keyword and name-value arguments) –

    • first positional vararg (string)

      plot title string

    • subsequent varargs

      passed to title function

    • ’no_date’

      disable automatic date string in title

Examples

Set x- and y-axis labels:

xyt('time (secs)', 'Engine Speed (RPM)');

Set x- and y-axis labels, omitting automatic date reference:

xyt('time (secs)', 'Engine Speed (RPM)', 'no_date');

Set x- and y-axis labels and title:

xyt('time (secs)', 'Engine Speed (RPM)', 'Engine Speed v. Time');

Set x- and y-axis labels and title, omitting automatic date reference:

xyt('time (secs)', 'Engine Speed (RPM)', 'Engine Speed v. Time', 'no_date');

Set x- and y-axis labels and title, with optional title font size setting:

xyt('time (secs)', 'Engine Speed (RPM)', 'Engine Speed v. Time', 'FontSize', 12);

Note

Sets label and title Interpreters to ‘none’, so underscores display properly

See also

xlabel, ylabel, title

graphics.lineat(val, varargin)

[h] = LINEAT(val, varargin)

Plots a horizontal line on the y-axis at val using superplot. Returns a handle to the lineseries object and supports all superplot varargs.

Exmaple:

lineat(10,’r’) % draws a horizontal red line at height 10 on the y-axis

See also superplot

graphics.gaxy

GAXY - grab plot x- and y- axes

Shortcut for gax and sax, typically used with saxy, saxyall

See also

axis, gax, sax, gay, say, saxy, saxall

graphics.fploth(varargin)
[lineseries] = FPLOTH(varargin)

Shortcut for: figure; plot; hold on;

Parameters:

varargin (optional keyword and name-value arguments) – plot arguments

Uses superplot instead of Matlab plot, but essentially the same. If no active figure exists, it is created.

Returns:

handle to line series

Return type:

line series handle

Example

Create a simple plot with two lines, hold and grid on. First line red, second line blue:

figure;
plothg([1 2 3], [4 5 6], 'r-');
plothg([0 1 2], [6 5 4], 'b-');

See also

figure, plot, hold, superplot

graphics.sazall

SAZALL - set plot z-axis for all active plots

Sets plot z-axis min and max values based on the workspace variables gaz1 and gaz2 respectively, for all active plots

Typically used with gaz

See also

axis, gax, gay, say, gaxy, saxy, saxall, gaz, saz

graphics.gaz

GAZ - grab plot z-axis

Sets workspace variables gaz1 and gaz2 with the min and max z-axis values, respectively, of the current plot

Typically used with saz

See also

axis, gax, sax, say, gaxy, saxy, saxall, saz

graphics.say

SAY - set plot y-axis

Sets plot y-axis min and max values based on the workspace variables gay1 and gay2 respectively

Typically used with gay

See also

axis, gax, sax, gay, gaxy, saxy, saxall, gaz, saz

graphics.saxy

SAXY - set plot x- and y- axes

Shortcut for sax and say, typically used with gaxy

See also

axis, gax, sax, gay, say, gaxy, saxall

graphics.saxall

SAXALL - set plot x-axis for all active plots

Sets plot x-axis min and max values based on the workspace variables gax1 and gax2 respectively, for all active plots

Typically used with gax

See also

axis, gax, gay, say, gaxy, saxy, saxall

graphics.plothg(varargin)
[lineseries] = PLOTHG(varargin)

Shortcut for: plot; hold on; grid on;

Parameters:

varargin (optional keyword and name-value arguments) – plot arguments

Uses superplot instead of Matlab plot, but essentially the same. If no active figure exists, it is created.

Returns:

handle to line series

Return type:

line series handle

Example

Create a simple plot with two lines, hold and grid on. First line red, second line blue:

figure;
plothg([1 2 3], [4 5 6], 'r-');
plothg([0 1 2], [6 5 4], 'b-');

See also

plot, hold, grid, superplot

graphics.saxyall

SAXYALL - set plot x-axis and y-axis for all active plots

Shortcut for saxall, sayall

Typically used with gax, gay, gaxy

See also

saxall, sayall

graphics.powerlines(varargin)
POWERLINES( varargin )

Draw lines of constant power in increments on the current plot axis, typically used with engine or motor map plots.

Parameters:

varargin (optional keyword and name-value arguments) –

  • ‘units’, str

    ’W’, ‘kW’ or ‘hp’ - hints that chart is in RPM & Nm, or RPM & ft-lbs.

  • ’convert’, numeric

    (requires ‘units’ to be supplied) provides an arbitrary power scale, for example if axes are unusual, like radians per second and inch-pounds instead of RPM and Nm

  • ’max’, numeric

    maximum power line in units (if supplied), taken as Watts if over 10,000 and no units are supplied, otherwise taken as kiloWatts if no units are supplied.

  • ’min’, numeric

    minimum power line in units (if supplied), taken as Watts if max is over 10,000 and no units are supplied, otherwise taken as kiloWatts if no units are supplied.

  • ’increment’, numeric

    distance, in units (if supplied) between power lines. If not supplied, it will be calculated to draw 11 lines between min and max power.

  • ’z_offset’, numeric

    height above chart to plot powerlines, default = 0, allows power lines to ‘hover’ if they interfere with other plot elements.

  • ’auto_refresh’, bool

    enable or disable powerline re-draw on plot resizing. Default value is true. Adds a listener to the plot, calls rescale_callback subfunction

Examples

Powerlines from 10 kW to 100 kW in 5 kW increments:

powerlines('min', 10, 'max', 100, 'increment', 5);

or:

powerlines('min', 10, 'max', 100, 'units', 'kW', 'increment', 5);

Powerlines from 10 hp to 100 hp in automatic increments:

powerlines('min', 10, 'max', 100, 'units', 'hp');

Powerlines from 10 kW to 100 kW in 5 kW increments, automatic refresh turned off:

powerlines('min', 10, 'max', 100, 'increment', 5, 'auto_refresh', false);

See also

rescale_callback (POWERLINES sub-function)

graphics.fplothg(varargin)
[lineseries] = FPLOTHG(varargin)

Shortcut for: figure; plot; hold on; grid on;

Parameters:

varargin (optional keyword and name-value arguments) – plot arguments

Uses superplot instead of Matlab plot, but essentially the same. If no active figure exists, it is created.

Returns:

handle to line series

Return type:

line series handle

Example

Create a simple plot with two lines, hold and grid on. First line red, second line blue:

figure;
plothg([1 2 3], [4 5 6], 'r-');
plothg([0 1 2], [6 5 4], 'b-');

See also

figure, plot, hold, grid, superplot

graphics.vlineat(val, varargin)

[h] = VLINEAT(val, varargin)

Plots a vertical line on the x-axis at val using superplot. Returns a handle to the lineseries object and supports all superplot varargs.

Exmaple:

vlineat(10,’r’) % draws a vertical red line at 10 on the x-axis

See also superplot

graphics.gridall

GRIDALL - turn x-, y- and z-axis grids on for all active plots

See also

grid

graphics.add_legend(legend_string, varargin)
[LEGH] = ADD_LEGEND( legend_string, varargin )

Adds legend_string to the current legend, if a legend does not exist it is created. Supports normal legend varargs

Parameters:
  • legend_string (str) – The legend string to add

  • varargin (optional keyword and name-value arguments) – optional arguments passed to the legend function

Returns:

handle to the current legend

Return type:

legend handle

Note

Sets legend Interpreter to ‘none’, so underscores display properly

See also

legend

graphics.ploth(varargin)
[lineseries] = PLOTH(varargin)

Shortcut for: plot; hold on;

Parameters:

varargin (optional keyword and name-value arguments) – plot arguments

Uses superplot instead of Matlab plot, but essentially the same. If no active figure exists, it is created.

Returns:

handle to line series

Return type:

line series handle

Example

Create a simple plot with two lines, hold and grid on. First line red, second line blue:

figure;
plothg([1 2 3], [4 5 6], 'r-');
plothg([0 1 2], [6 5 4], 'b-');

See also

plot, hold, superplot

graphics.fplotg(varargin)
[lineseries] = FPLOTG(varargin)

Shortcut for: figure; plot; grid on;

Parameters:

varargin (optional keyword and name-value arguments) – plot arguments

Uses superplot instead of Matlab plot, but essentially the same. If no active figure exists, it is created.

Returns:

handle to line series

Return type:

line series handle

Example

Create a simple plot with two lines, hold and grid on. First line red, second line blue:

figure;
plothg([1 2 3], [4 5 6], 'r-');
plothg([0 1 2], [6 5 4], 'b-');

See also

figure, plot, grid, superplot

graphics.newhist2d(binvar_x, bindef_x, binvar_y, bindef_y, rate, time, scale_min, scale_max, varargin)
[ax, ch, hist2d_bindata] = NEWHIST2D(binvar_x, bindef_x, binvar_y, bindef_y, rate, time, scale_min, scale_max, varargin)

Calculate 2D integral histogram, and optionally plot it

Parameters:
  • binvar_x – data to bin on the x axis

  • bindef_x – bin boundaries for binvar_x

  • binvar_y – data to bin on the y axis

  • bindef_y – bin boundaries for binvar_y

  • rate – data in units per second to integrate into bins

  • time – time vector for rate data

  • scale_min – minimum integral will be scaled to this value, requires scale_max. Can be used to normalize data within a known range

  • scale_max – maximum integral will be scaled to this value, requires scale_min. Can be used to normalize data within a known range

  • varargin (optional keyword and name-value arguments) –

    • ‘no_plot’

      calculate 2D histogram but disable plotting

Returns:

axis handle, contour handle, and 2D histogram data

Return type:

tuple

graphics.gay

GAY - grab plot y-axis

Sets workspace variables gay1 and gay2 with the min and max y-axis values, respectively, of the current plot

Typically used with say

See also

axis, gax, sax, say, gaxy, saxy, saxall

graphics.saz

SAZ - set plot z-axis

Sets plot z-axis min and max values based on the workspace variables gaz1 and gaz2 respectively

Typically used with gaz

See also

axis, gax, sax, gay, gaxy, saxy, saxall, saz

Code Index