# TSDT14 Signal Theory

## Laborations autumn 2017

### Hints regarding laborations

#### Contents

#### Write Functions

You will do several similar calculations, which typically end in graphs. It is therefore a good idea to start writing functions from the beginning, which you call with various arguments to achieve what you want to achieve. Especially, this holds for the power spectral density estimation.

#### Help in Matlab

Matlab has a traditional help function that you reach through the menu
choice
**Help/MATLAB Help**.
There is amount of information that you can find there is
overwhelming,
and most of the information that is related to these laborations is
under **MATLAB** and **Signal Processing Toolbox**.

Matlab also has a line-based help.
To get help about a command, e.g. ** filter**,
type

help filter

in the interactive window.

#### Normalized Frequencies

MatLab (actually Signal Processing Toolbox)
has its own idea of what is meant by normalized frequencies.
The following is in the help text about the command
** butter**:

BUTTER Butterworth digital and analog filter design. [B,A] = BUTTER(N,Wn) designs an Nth order lowpass digital Butterworth filter and returns the filter coefficients in length N+1 vectors B (numerator) and A (denominator). The coefficients are listed in descending powers of z. The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.

There are similar formulations in the help texts of all other filter
generating functions.
Note that the normalized frequency 1 corresponds to *half* the
sampling frequency,
and not the *whole* sampling frequency as we are used to.
Thus, if you want the coefficients of a Butterworth filter of degree 10,
and normalized cut-off frequency 0.1 according to our definition,
you get that with the command

[b,a]=butter(10,0.2)

#### Plots

Don't forget that you can control the appearance of plots by supplying
extra arguments to the command ` plot`.
As an example, we create two vectors:

x=0:16; y=sin((pi/8)*x)

Then we plot ` y` against

`:`

**x**plot(x,y)

Result: solidline.png

Now, we plot with circles:

plot(x,y,'o')

Result: circles.png

Finally, we create a graph that resembles the way time-discrete signals are presented in many Signals & Systems course books, but with green sticks and blue circles:

plot(x,y,'bo') hold on for i=1:length(x) plot([x(i) x(i)],[0 y(i)],'g-') end plot([0 16],[0 0],'k-') hold off

Result: total.png

Note that you can essentially achieve the same result with the command
`stem`.

There are more ways to control the appearance of plots.
See the help of the command ` plot`.

#### Adjusting Plots

When you have created a graph in Matlab, you might not be completely satisfied with how it is presented. You might want to adjust the thickness of lines, or correct the grading of the axes, or something else. Matlab has a special tool for that. First choose the graph you want to adjust. Then type

plottools on

in the interactive window. This gives you a set of editing tools around the graph. When you are done, type

plottools off

in the interactive window. The editing tools will then dissapear.

Page responsible:
Mikael Olofsson

Last updated: 2017 08 22 12:08