Definitions for amplitude spectrum and phase spectrum

I want to help someone with a homework in signal processing, and the courses he provided are some slides, without clear definitions in them. I am required in solving a problem to represent the amplitude spectrum and the phase spectrum of a given signal. I searched the internet and didn't found the definitions of these two. I want to create a Matlab script for these, but if I don't know the definitions I cannot do that. Please give me the definitions for these.

• Amplitude spectrum
• Phase spectrum

If there is a Matlab command, or some other program which plots these spectrums directly, I would be very interested. Thank you.

• See e.g. this. – user276 Nov 1 '11 at 14:02
• mathworks.com/help/toolbox/control/ref/bode-plot.html – datageist Nov 1 '11 at 14:04
• Do you mean a discrete signal or a periodic signal (you said both with an "or" in there)? If you're wanting amplitude/phase plots of a continuous-time signal (that might be periodic), then you'll use different methods than if you have a discrete-time signal. – Jason R Nov 1 '11 at 14:20
• I meant for a discrete signal or discrete periodic signal. – Beni Bogosel Nov 1 '11 at 14:29

1 Answer

Beni I think you want something like this:

samplingFrequency = 1000; % / Hz
signalFrequency = 50;     % / Hz
signalLength = 500;
signal = cos(2*pi*signalFrequency./ samplingFrequency .*[0:1:signalLength - 1]);
[hh ff] = freqz(signal, 1, 2048, samplingFrequency);
figure(10);
plot(ff,10*log10(abs(hh)));
ylabel('Amplitude in log scale');
xlabel('Frequency / Hz');
figure(20);
plot(ff, angle(hh));
ylabel('Phase');
xlabel('Frequency / Hz');


You do have MATLAB correct?... if you do try it and let me know how else I can help.

Well, a couple things. First off, remember, since this is a digital signal, it means of course that it was sampled at some frequency $samplingFrequency= 128 or 127$ in your case. The physical frequency of your signal in this case seems to be $signalFrequency = 21$.

The ratio of $\frac{signalFrequency}{samplingFrequency}$ is equal to the $f_0$ in your case. This is called the 'digital frequency'.

For your problem it sounds like he also wants you to fix the fft size, (change the 2048 in my code to 128) and the rest of the numbers as I described and run the code. Does he mention how long he wants your signal to be?

• Thank you for your answer and your time, but I would like something like this: jhu.edu/signals/spectra/ampscale.html I want to create separate graphs for amplitude(magnitude) spectrum and phase spectrum. – Beni Bogosel Nov 1 '11 at 20:30
• @BeniBogosel If you run the code it will give you the plots. I edited the answer to include them for you. – Spacey Nov 1 '11 at 20:36
• Ok. Thank you, I've got those polts. One of my problems says to calculate the amplitude and phase spectrum for the signal $x(n)=\cos(2\pi f_0 n)$ in $N=128$ points for $f_0=21/128$ and $f_0=21/127$ and explain the differences. That means that signal length is 128, sampling sequence is 1, and frequency is $f_0$? – Beni Bogosel Nov 1 '11 at 20:59
• @BeniBogosel I edited the end of the answer since it was too long to type here. Have a look and tell me how else I can help. – Spacey Nov 1 '11 at 21:57
• Thank you. It looks a bit different. I will study this problem more tomorrow. Thank you very much for your help. :) – Beni Bogosel Nov 1 '11 at 22:12