Digital Signal Processing Reference
In-Depth Information
sprintf(Error - magnitude and phase must be same length)
end
% We want this for 2 repetitions, and num_points per rep.
step = 2/(freq*num_points);
t = 0:step:2*(1/freq);
clear x;
x = 0;
for i=1:length(mag)
x = x + mag(i)*cos(2*pi*i*freq*t + phase(i));
end
my_title = sprintf(Harmonic signal: %d sinusoids,length(mag));
plot(t,x);
title(my_title);
xlabel(time (sec));
ylabel(Amplitude);
For example, the following commands plot x 2 (t) from above. It is assumed that
the code from above is saved with \plotharmonic.m" as the lename.
Mag = [ 0.1 0 1.3 0.5];
Phase = [ -pi/6 0 pi 2*pi/3];
plotharmonic(100, Mag, Phase);
% Fundamental freq. is 100 Hz
The resulting plot can be seen in Figure 4.7.
One additional piece of information is if there is a vertical shift of the signal.
That is, what if the graph shown in Figure 4.7 was not centered around the x-axis?
This can be accomplished by adding a constant to the signal. For example, if we add
100 units to the signal, it would look the same, but it would be centered around the
line y = 100. This piece of information can be added to the above harmonic signal
format, simply by including the term a 0 cos(2(0)f 0 t + 0 ). Starting the multiples
of f 0 at zero means that the rst component is simply a constant. There is no
need to specify a 0 term, since cos( 0 ) would just be a constant, and a 0 already
species this. Therefore, we will assume 0 is zero. This term is often called the
DC component, for Direct Current.
Example:
For the signals below, say which ones are harmonic and which are not. If they
Search WWH ::




Custom Search