You are on page 1of 4

ExerciseSheet01

Intro

This assignment is about getting started and basic MATLAB programming.


Before you start working make sure you have :

• MATLAB installed
• reviewed MATLAB Basics

– beginners’ tutorials
– examples (esp. Working with arrays)

MATLAB

• Install MATLAB by following the guide .


• Post a screenshot of MATLAB running on the machine you intend to use for the exercises
thereby demonstrating successful installation.

Please consult support in case of difficulties.

Submission

Please submit one zipped file named ID\_ES01.zip where ID stands for your id (e.g.
se14m666\_ES01.zip) containing:

• An m-file called ES01.m which contains a (well documented) cell for each problem on this
sheet or individual m-files named after the problems (e.g. ES01_01_vector.m).
• All additional functions and/or files (such as images)

Any comments/explanations should be included in the m-files as comments.


Complete the checklist before submission!

1. Vector

Create a vector t with N values from −2π to 2π for N = 8, 16, 512


Then,

• shift it by 4, 8, 256 positions to the left


• transpose it
• concatenate t and the shifted version
– horizontally
– vertically

MSE-MBV-WS1617 1
Abbildung 1: SineWavePlot

2. SineWave

Create a vector y with the same number of elements as t. Let the values yi = sin(ti ) with i = 1 . . . N
and plot y versus t for all values of N in different colors in one plot (Fig. SineWavePlot).
Set all negative values vi in y to −vi and display in a separate figure. Use a logical array!

3. Gauss

Write a function gauss1d(x, σ) that returns


 
x 2
1 − 2σi 2
yi = √ e
2πσ

Note: x can be a vector, the function should then return a vector.


Visualize gauss1d(x, σ) for x ∈ [−10, 10] with 0.2 spacing and create three subplots for σ = 1, 3, 6.
Create a fourth subplot which contains the graphs for σ = 0.1, 1, 3, 6 in one plot. Label the y-axis,
display titles and a grid for all subplots. (See Fig. Gauss)

4. Matrices

Create a 2 dimensional matrix of some test data (at least 100x100) and then

• calculate and print

– sum of rows
– sum of columns
– mean of rows
– mean of columns
– count of values below a certain threshhold
– mean of values below that threshhold

• substitute all values below a threshhold with a different value

• transpose the matrix

MSE-MBV-WS1617 2
Abbildung 2: Gauss

• reshape to a 2xn matrix


• add random noise to the data
• create a neat plot of all calculated values

MSE-MBV-WS1617 3
Checklist:

• I have used and/or feel comfortable using at least four of the following functions for matrix
creation

– Repmat
– Linspace
– Zeros
– Ones
– Cat
– Diag
– Eye

• I have used and/or feel comfortable using at least four of the following functions concerning
matrix dimensions

– Length
– Ndims
– Numel
– Size
– Height
– width

• I have used and/or feel comfortable using at least four of the following functions for matrix
reshaping

– circshift
– diag
– flip
– fliplr
– fliud
– reshape
– sort
– shiftdim
– transpose

• I can calculate the following values of an array without using loops:

– Min
– Max
– Mean
– Median
– Sum

• I have frequently used the colon operator (:) and end


• I have NOT used

– For loops (or any other kind of loop)

MSE-MBV-WS1617 4

You might also like