# Programming Fourier Transforms MATLAB Programming Task

Description

Matlab programming task  on Fourier Transforms

2 attachmentsSlide 1 of 2attachment_1attachment_1attachment_2attachment_2

Unformatted Attachment Preview

E80 Matlab Assignment 4
FFT – The Fast Fourier Transform
For this assignment, you will use the FFT (Fast Fourier Transform) to calculate the major frequency
components of the migratory motion of a particular species of fish. Fig. 1 illustrates the migratory
motion of 3 individual fish (yellow, red, blue). For each fish, there are two clusters of fish position
observations, and the fish migrate back and forth between these two cluster areas.
Figure 1: Fish positions logged over a 3 month period using a Vemco acoustic tracking system.
Each color (red, blue, yellow) corresponds to a different individual fish. The fish habitat is located
in Big Fisherman Cove, Catalina Island, CA where stationary acoustic receivers were placed along
the seafloor to log signals broadcasted from acoustic transmitters attached to the fish.
1. To complete the remainder of the assignment, you will need the file fishData.mat. Please
download the file and put it somewhere accessible to Matlab, (e.g. in the MATLAB directory
often found under the Documents directory in the file structure).
Making Waves
2. Create a new script file called waves.m. Use the script to write the following code:
3. Create a time sequence vector called times that start at 0, increment in step sizes of 0.01
seconds, and whose last element is 8.99 seconds.
4. Check that the vector is the correct length of 900 using the size function, and set N = 900.
Make sure you understand why it should be 900.
5. Create a cosine wave signal called wave1 that has an amplitude of 10, and a frequency of
0.5*2π rad/s. The signal is sampled version of a continuous signal, where the sampling
period is 0.01 seconds and the signal spans a time length of 8.99 seconds. Hint: use the
times vector you created in step 3.
6. Create a second cosine wave signal called wave2 that has an amplitude of 2, and a
frequency of 2.0*2π rad/s. The signal should also have a sampling period of 0.01 seconds
and spans a time length of 8.99 seconds.
7. Plot both signals as a function of time in black on a single figure.
8. Create a third signal called sumWaves that is the sum of both waves. Plot this third signal
on the same figure, but in red. It should be clear that this third wave has visible components
of wave1 and wave2. Save an image of the plot and add to your submission sheet. Be sure
all axes are labelled.
Windowing
9. If we want to take the FFT of sumWaves, we should window it to make sure it is close to
periodic. Use the hann function to create a signal h that is the shape of hann function and
of length N.
10. Create a vector sumWaves_Windowed that is created by multiplying each element of h
with sumWaves. Plot sumWaves_Windowed, save it as an image, and add the image to the
submission sheet.
A Discrete Fourier Representation
In this section, you will create a Fourier representation of the signal sumWaves_Windowed.
11. Recall the following equations allow you to calculate the coefficients X[k] of the sinusoid
building blocks of a discrete time signal x[n].
Use these equations to calculate the coefficients X[k] for the signal sumWaves_Windowed,
and store them in a vector called X. It helps to first determine the values of N and x in the
equation.
12. Plot the coefficients X[k] as a function of k using the stem function. E.g. stem(X). Save this
image and insert it into your submission sheet. Be sure all axes are labelled.
13. Change the x axis so that the stems are plotted as a function of real time frequency.
Specifically, each stem for coefficient X[k] should be plotted as a function of its frequency
k*f0, where f0 is the fundamental frequency of the Fourier representation associated with
the basis function. E.g the kth basis function has frequency of k*f0.
An important point to understand is that the sampling frequency and number of samples
determine f0. In this case the sampling frequency fs = 1/0.01s = 100 Hz. The fundamental
frequency is f0 = fs /N = 100/900 Hz = 0.111 Hz.
To change our x axis, create a vector called frequencies that is the same length as the
coefficients vector X, but increments by f0. E.g.
frequencies = [0:N-1]*f0;
14. Compare the two main peaks of the stem plot with the amplitude and frequencies of the
two sinusoids of which sumWaves was built. Do they match? If not, ask for help.
15. Repeat steps 9 through 12, but use the fft function. Compare your plots from step 11 (i.e.
the stem plot created with the equation in step 9 with the stem plot created using fft). Do
they match?
16. Save an image of one of your two stem plots as a function of frequency. Attach to your
submission sheet.
Fourier representation of a Data set
In this section, you will use the fft function to determine the major frequency components of a
signal representing the migratory motion of fish.
14. Load the data from the file fishData.mat.
15. Plot the x data as a function of t. Hold on. Plot the y data as a function of t. Observe any
periodic behavior, noting the x axis has units of days, i.e. t is provided in units of days. Save
16. Apply the fft function to the x data. Use the stem function and plot the fft coefficients as a
function of frequency as in step 11. Do the fish traverse back and forth between the two
locations once a day (e.g. in response to the sun rising/setting) or twice a day (e.g. in
E80 Matlab Submission 4
FFT – The Fast Fourier Transform
1. A plot of your waves signals as a function of time. Include both the plots from
part 8 and 10.
2. A stem plot of your X[k] values as a function of k
3. A stem plot of your X[k] values as a function of frequency.
4. A plot of x (from the fishData.m file) as a function of time.
5. Do the fish migrate once or twice a day?

attachment

Tags:
programming

matlab

Discrete Fourier Representation

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

## Reviews, comments, and love from our customers and community:

### Article Writing

Keep doing what you do, I am really impressed by the work done.

Researcher

### PowerPoint Presentation

I am speechless…WoW! Thank you so much!

#### Stacy V.

Part-time student

### Dissertation & Thesis

This was a very well-written paper. Great work fast.

Student

### Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time.

Student

### Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more.

Student

### Essay (Any Type)

On time, perfect paper

Student

### Case Study

Awesome! Great papers, and early!

#### Kaylin Green

Student

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Researcher

### Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. Transparent

Customer

Perfect!

Student