When you compared your two graphs using MATLAB you saw obvious differences, mainly in the length and the amplitudes of the signals. The signals you plotted can be interpreted as functions of time and
, to compare them we should look at
One of the problems you should have encountered is that these two functions are not defined on the same interval. To remedy this find the approximate starting
point and end point of the word in the two signals y1 and y2. Then identify the length
of both words. Let M be the longer one, and let be the starting point of the word in the first signal. Carry out the following commands:
x1=zeros(M,1); {\it here and in the following M is the number you found above}
for j=1:M x1(j)=y1(j+n_1-1); endor use
x1(1:M)=y1(n_1:n_1+M-1);Repeat this for the second signal.
Now x1 and x2 are vectors which still contain the same signal as y1 and y2, but they are of the same length. Plot the two new signals and compare them. Next we want to compute the norm of the difference to do this type
norm=max(abs(x1-x2))Is this number small? Explain your reasoning.
To get a better idea whether this number is small or not compute the norms of x1 and x2
norm1=max(abs(x1)) norm2=max(abs(x2))and compare them to the norm of the difference.
As next exercise in this section we want to compare the signal x1 to itself. To do this create a vector x3
x3=5*x1;
This is the same signal, only 5 times as loud as the original. Compute the norms of x1, x3 and x1-x3, and answer the following questions:
In order to solve this problem you should have thought about unit vectors. So in the last computer exercise of this section we will normalize x1 and x2 and compare them. To do this we use two methods, in the first we normalize by the maximal entry in the vector. To do this
z1=x1/max(x1);and repeat this for x2. Then compute the norms of x1, x2 and x1-x2 and compare them. Is the result for x1-x2 small compared to the norms of x1 and x2? And is the result better or worse than the result for the un-normed sounds?
In linear algebra we learned a different method to compute norms or length' of vectors. To compute the traditional length do
leng1=0; for j=1:M leng1=leng1+x1(j)^2; end leng1=sqrt(leng1); q1=x1/leng1;or use the vectorized command
leeng1=sqrt(sum(abs(x1).^2));This gives you a unit vector in the traditional sense. Compute this also for x2 and repeat the comparisons from above.