Within Octave/Matlab, type in the following commands:
N=8; % number of points phase=0; % phase shift t=(0:N-1)/N; % time goes on half open interval, [0,1), e.g. from 0 to almost 1 fc=1; % carrier frequency is 1; fracfreq = 1/N g=sin(2*pi*fc*t+phase);Now plot the result with the following command:
plot(g)This shows the N points of the sine wave, connected by straight lines (the default for the "plot" command). You can also experiment with other ways of plotting.
For example, try the "stem" command (you'll find "stem.m" in the distribution directory for lab1, for Octave, or if you're using Matlab, "stem" is an included m file).
To print the plots, here is how you can use the gset command.
Now try increasing the frequency, e.g. try:
fc=2; g=sin(2*pi*fc*t+phase); stem(g);To see the numbers in "g", simply type "g" and press return:
g = 0.00000 1.00000 0.00000 -1.00000 -0.00000 1.00000 0.00000 -1.00000Notice that there are four samples per cycle. Are we below the Nyquist rate?
Is it possible to reconstruct the signal from these points?
For example, try joining the points with a straight line, as in the default plotting command:
plot(g)
Is this an accurate reconstruction? If not, why not?
What assumptions might you make in recovering a true and accurate reconstruction of the signal.
fc=4; % carrier freq. 4, so that fracfreq = 4/N, e.g. 4/8=1/2 in this case. g=sin(2*pi*fc*t+phase); stem(g);
What do you observe?
Explain what you see.
Try printing out the values of g. Comment on their magnitude, and the reliability of this data.
Aliasing: try increasing the frequency further:
fc=7; % carrier freq. 7, so that fracfreq = 7/N, e.g. 7/8 in this case. g=sin(2*pi*fc*t+phase); stem(g);How many cycles of the sinewave to you observe? What is the fundamental period of this signal?