# MATLAB

#### greenjames287

Joined Sep 30, 2015
11
I am having trouble with this task in MATLAB and cant seem to get my graphs right. The following is what I need to do.

1. Generate a signal with frequencies 100Hz, 200Hz and 350Hz, using sample freq of 1kHz generate 1s of data.
2. Plot the signal and its Discrete Fourier Transform
3. Find the frequency response of an LTI system that filters out the higher and lower frequencies using Fourier Transform.
4. Produce magnitude and phase plot of frequency response
5. Plot impulse response of the system

I believe I have done 1-3 correctly but I don't think the graphs for 4 and 5 are correct. Any advice on where I am going wrong would be great, I have only been doing MATLAB for a few weeks.

Last edited:

#### greenjames287

Joined Sep 30, 2015
11
Since nobody is replying can someone delete this thread?

#### shteii01

Joined Feb 19, 2010
4,644

#### greenjames287

Joined Sep 30, 2015
11
Thanks, but I am more stuck on plotting the frequency response rather than the fourier transform.

#### shteii01

Joined Feb 19, 2010
4,644
Your signal got three frequencies in it, so your frequency plot should have 3 spikes. Since you don't say what the problem is... nobody see any point trying to figure it out and I don't have MatLab loaded on this pc so I can not run your code even if I wanted to.

#### greenjames287

Joined Sep 30, 2015
11
Your signal got three frequencies in it, so your frequency plot should have 3 spikes. Since you don't say what the problem is... nobody see any point trying to figure it out and I don't have MatLab loaded on this pc so I can not run your code even if I wanted to.
I have 3 spikes on the frequency plot of the input but my problem is I am not sure if H is calculated correctly and if the phase and magnitude plots of it are correct. If I calculate the impulse response , h=ifft(H), and plot the convolution of that with the input I believe I should be getting just the middle frequency, which I am not. Graphs are attached.

#### shteii01

Joined Feb 19, 2010
4,644
You are right, your magnitude plot got three spikes, it should have just one. In number 3 they are asking you to make and apply bandpass filter, where the filter blocks the 100 Hz and 350 Hz frequencies. It looks like you should work on that part, get the frequency plot that has that one spike at 200 Hz. Then do the magnitude and phase.

#### greenjames287

Joined Sep 30, 2015
11
You are right, your magnitude plot got three spikes, it should have just one. In number 3 they are asking you to make and apply bandpass filter, where the filter blocks the 100 Hz and 350 Hz frequencies. It looks like you should work on that part, get the frequency plot that has that one spike at 200 Hz. Then do the magnitude and phase.
Should the magnitude plot have two or one spike? I fixed an error in that example I wrote so the plot of what should be the output has 1 spike at 200Hz. Calculating H and plotting magnitude and phase gives these graphs.

#### shteii01

Joined Feb 19, 2010
4,644