# Matlab Functions & Scripts - mfiles

This page introduces and presents links to Maltab
functions and scripts that are useful for this course. By
clicking the link below a window will appear with the code for the
mfiles. You can save this as a simple text file with the same
function name (extension is always .m) directly with your web
browser, or you can copy and paste into a text editor and save it as
a text file. You can execute this function or script in Matlab
provided the file is in your working directory or Matlab path.
Make sure you save the function files using the same name as their
function described in the program (same as the link name).

## Scripts

### tutor.m
is a tutorial script that introduces the basic Matlab syntax,
functions, and operation, written by Kyle Dippery

### instpower.m
is a script that computes and plots instantaneous power based on
a voltage and load impedance.

### tfex.m
is a script that uses function tfeval.m
to compute and plot a transfer function (phase and magnitude) on both
log (Bode) and linear scales.

### parallel_filter.m
is a script that uses function tfeval.m
to compute a TF (phase and magnitude), and then creates a Bode plot
for an example filter circuit that sums and scales the outputs of 3
individual band-pass filters.

### series_filter.m
is a script that computes a TF (phase and magnitude), and then
creates a Bode plot for an example filter circuit that is the result
of 2 low-pass filters in series.

### TOH.m
is a script that performs a series of computations and plots that
demonstrate starting with the differences between a normal threshold
of hearing (TOH) curve and one derived from a human subject based on
the number of audible counts of a decreasing tone, to a TF that
represents the frequency dependent gain for a filter to correct for
the hearing losses. The process is explained in the scripts
comments.

### plot2_1.m
is a script that plots a transfer function as a Bode and as a
linear plot. The frequency range of the axis is determined through a
pole-zero analysis.

### plot4_1.m
is a script that plots the transfer function magnitudes of a
first and second order low-pass filter.

### plot4_2.m
is a script that plots the transfer function magnitude of the sum
of 3 band-pass filters.

### plot4_3.m
is a script that plots the transfer function magnitude of the
product of 2 low-pass filters.

### ex6.m
is a script that finds filter parameters for a combined series
low-pass and high-pass combination that minimize mean and variance
criteria with respect to a target transfer function magnitude.

### opt1.m
is a script that tries to minimize the variance error between a
target transfer function and a proposed transfer function synthesized
from 3 parallel band-pass filters. It adjusts the bandwidth of the
mid-frequency filter over a range of values and finds the bandwidth
that minimizes the error. This script also plots each trial to get a
movie-like display showing how the synthesize filter compares to the
target specification at each iteration.

### soln13_3.m
is a script that solves for characteristic equation roots, forced
solutions, and undetermined coefficients for a multiple source
example.

### plot14_1.m
is a script that plots the response of a linear time-invariant
system to a complex input waveform example.

## Functions

### tfeval.m
Generates complex points of a transfer function based on its
polynomial description

### lpf1.m
Generates complex points of a first order low-pass filter
transfer function

### hpf1.m
Generates complex points of a first order high-pass filter
transfer function

### bpf2.m
Generates complex points of a second order band-pass filter
transfer function

### uimpulse.m
The unit impulse function

### ustep.m
The unit step function

### uramp.m
The unit ramp function

### autest.m
Creates tones to test levels of audibility

### thrhearvals.m
- Interpolated table value for absolute threshold of hearing values.
Input frequencies in audible range and the corresponding dB values
for the TOH are returned.