The original signals
(i)
Using the program of your choice, average your 10
"abracadabras" from your previous assignment, and plot the result. Be
sure to line up the signals prior to the averaging operation. Submit your code
with your plot
Cross-correlation of my voices
Shift of of my voices
Average of my voices
(ii)
Plot the result
of the autocorrelation Rx[n]for
each of your 10 "abracadabra" signals, as well as the average of the
10 autocorrelations. Also, plot the autocorrelation for the averaged signal
from part (i) above, and compare and comment the two final plots.
Plot the result of
the autocorrelation Rx[n]for
each of your 10 "abracadabra" signals
Plot
the autocorrelation for the averaged signal from part (i) above
Comment:
Autocorrelation is used to compare a signal with a
time-delayed version of itself, because it can tell us the time interval over
which a correlation in noise exits. The
average of autocorrelation plot showed a lot of noises in the signal. It is difficult to find covariance between
the time series.
Cross-correlation
compares 2 random signals, and then defines the average value of the signal at
sample time. The average of cross
correlation plot showed less noise compare with the autocorrelation. Cross-correlation is also a convolution.
%Minh Anh Nguyen
%ECE: 537 Biomedical Signal Processing; CSU
%email: minhanhnguyen@q.com
%Homework 3
close all;
clc;
figure;
%Read in the sound
%returns the sample
rate(FS) in Hertz
%N = number sample
%the number of bits per
sample (BITS) used to encode the data in the file
ax(1)= subplot (3,2,1);
myvoice1 = audioread('J:\BIOM_Signal_processing\HW2\Aka1_a.wma');
[y1, fs1] = audioread('J:\BIOM_Signal_processing\HW2\Aka1_a.wma');
N = length(myvoice1);
%%player=audioplayer(y1,N);
play(player)
t1 =
(0:1:length(myvoice1)-1)/fs1;
plot(t1, myvoice1);
title ('My voice
[Abrakakabra]#1 Number of sample 229364')
xlabel('time (sec)');
ylabel(' signal
strength')
axis tight
grid on;
ax(2)=subplot (3,2,2);
myvoice2 = audioread('J:\BIOM_Signal_processing\HW2\ala_2.wma');
[y2, fs2] = audioread('J:\BIOM_Signal_processing\HW2\ala_2.wma');
N2 = length(myvoice2);
t2 =
(0:1:length(myvoice2)-1)/fs2;
plot(t2, myvoice2);
title ('My voice
[repeat Abrakakabra]#2 Number sample 370661')
xlabel('time (sec)');
ylabel(' signal
strength')
axis tight
grid on;
ax(3)=subplot (3,2,3);
myvoice3 = audioread('J:\BIOM_Signal_processing\HW2\alka3.wma');
[y3, fs3] = audioread('J:\BIOM_Signal_processing\HW2\alka3.wma');
N3 = length(myvoice3);
t3 =
(0:1:length(myvoice3)-1)/fs3;
plot(t3, myvoice3);
title ('My voice
[repeat Abrakakabra]#3 number of sample 376790')
xlabel('time (sec)');
ylabel('signal
strength')
axis tight
grid on;
ax(4)= subplot (3,2,4);
myvoice4 = audioread('J:\BIOM_Signal_processing\HW2\Alka_4.wma');
[y4, fs4] = audioread('J:\BIOM_Signal_processing\HW2\Alka_4.wma');
N4 = length(myvoice4);
t4 =
(0:1:length(myvoice4)-1)/fs4;
plot(t4, myvoice4);
title ('My voice
[repeat Abrakakabra]#4 Number of sample 247798')
xlabel('time (sec)');
ylabel('signal
strength')
axis tight
grid on;
ax(5)= subplot (3,2,5);
myvoice5 = audioread('J:\BIOM_Signal_processing\HW2\Alka_5.wma');
[y5, fs5]= audioread('J:\BIOM_Signal_processing\HW2\Alka_5.wma');
N5 = length(myvoice5);
t5 =
(0:1:length(myvoice5)-1)/fs5;
plot(t5, myvoice5);
title ('My voice
[repeat Abrakakabra]#5 number of sample 266232')
xlabel('time (sec)');
ylabel('signal
strength')
axis tight
grid on;
ax(5)= subplot (3,2,6);
%ax(6)= subplot (2,2,1);
myvoice6 = audioread('J:\BIOM_Signal_processing\HW2\Aka_6.wma');
[y6, fs6] = audioread('J:\BIOM_Signal_processing\HW2\Aka_6.wma');
N6 = length(myvoice6);
t6 =
(0:1:length(myvoice6)-1)/fs6;
plot(t6, myvoice6);
title ('My voice
[repeat Abrakakabra]#6 number of sample 241624')
xlabel('time (sec)');
ylabel('signal
strength')
axis tight
grid on;
figure;
ax(7)=subplot (2,2,1);
myvoice7 = audioread('J:\BIOM_Signal_processing\HW2\alk_7.wma');
[y7, fs7] = audioread('J:\BIOM_Signal_processing\HW2\alk_7.wma');
N7 = length(myvoice7);
t7 =
(0:1:length(myvoice7)-1)/fs7;
plot(t7, myvoice7);
title ('My voice
[repeat Abrakakabra]#7 number of sample 303099')
xlabel('time (sec)');
ylabel('signal
strength')
axis tight
grid on;
ax(8)=subplot (2,2,2);
myvoice8 = audioread('J:\BIOM_Signal_processing\HW2\alk8.wma');
[y8, fs8] = audioread('J:\BIOM_Signal_processing\HW2\alk8.wma');
N8 = length(myvoice8);
t8 =
(0:1:length(myvoice8)-1)/fs8;
plot(t8, myvoice8);
title ('My voice
[repeat Abrakakabra]#8 number of sample 270333 ')
xlabel('time (sec)');
ylabel('signal
strength')
axis tight
grid on;
%figure;
ax(8)=subplot (2,2,3);
myvoice9 = audioread('J:\BIOM_Signal_processing\HW2\ala_9.wma');
[y9, fs9] = audioread('J:\BIOM_Signal_processing\HW2\ala_9.wma');
N9 = length(myvoice9);
t9 =
(0:1:length(myvoice9)-1)/fs9;
plot(t9, myvoice9);
title ('My voice
[repeat Abrakakabra]#9 number of sample 206829 ')
xlabel('time (sec)');
ylabel('signal
strength')
axis tight
grid on;
%figure;
ax(9)=subplot (2,2,4);
myvoice10 = audioread('J:\BIOM_Signal_processing\HW2\aka_10.wma');
[y10, fs10] = audioread('J:\BIOM_Signal_processing\HW2\aka_10.wma');
N10 = length(myvoice10);
t10 =
(0:1:length(myvoice10)-1)/fs10;
plot(t10, myvoice10);
title ('My voice
[repeat Abrakakabra]#10 number of sample 169961 ')
xlabel('time (sec)');
ylabel('signal
strength')
axis tight
grid on;
%%linkaxes(ax,'x') %% link all “x”
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%(i) Using the program of
your choice, average your 10 "abracadabras" from your previous
%assignment, and plot the result. Be sure to line up the signals prior to the
averaging operation. %Submit your code with your plot.
%% line up the signals
prior to the averaging operation
%Compute the
cross-correlations between the eight pairs of signals. Normalize them so their
maximum value is one.
y2new = y2(:,1); %% create signal in 1D
y1new = y1(:,1); %% signal 1
y3new = y3(:,1); %% create signal in 1D
y4new = y4(:,1); %% create signal in 1D
y5new = y5(:,1); %% create signal in 1D
y6new = y6(:,1); %% create signal in 1D
y7new = y7(:,1); %% create signal in 1D
y8new = y8(:,1); %% create signal in 1D
y9new = y9(:,1); %% create signal in 1D
y10new = y10(:,1); %% create signal in 1D
%%% correlattion of
signals. Normalize them so their maximum value is one.
[v21,lag21]=xcorr(y2new,y1new); %% correlattion of signal 1 and 2
v21 = v21/max(v21);
figure;
subplot (7,1,1);
plot(lag21,v21);
title ('lag of my
voice [repeat Abrakakabra]#1 and # 2 ')
xlabel('time (sec)');
ylabel('signal
strength');
max(v21);
find(v21 == 1); %% find the value of signal 1
lag21(find(v21==1)); % find the lag value
%%% Signal 3
[v31,lag31]=xcorr(y3new,y1new); %% correlattion of signal 1 and 2
v31 = v31/max(v31);
%figure
subplot (7,1,2);
plot(lag31,v31);
title ('lag my voice
[repeat Abrakakabra]#1 and # 3 ')
xlabel('time (sec)');
ylabel('signal
strength');
max(v31);
find(v31 == 1); %% find the value of signal 1
lag31(find(v31==1)); % find the lag value
%%% Signal 4
[v41,lag41]=xcorr(y4new,y1new); %% correlattion of signal 1 and 2
v41 = v41/max(v41);
figure
%subplot (7,1,3);
plot(lag41,v41);
title ('Lag of my
voice [repeat Abrakakabra]#1 and # 4 ');
xlabel('time (sec)');
ylabel('signal
strength');
max(v41);
find(v41 == 1); %% find the value of signal 1
lag41(find(v41==1)); % find the lag value
%%% Signal 5
[v51,lag51]=xcorr(y5new,y1new); %% correlattion of signal 1 and 2
v51 = v51/max(v51);
figure
subplot(8,1,1);
plot(lag51,v51);
title ('lag of my
voice [repeat Abrakakabra]#1 and # 5 ');
xlabel('time (sec)');
ylabel('signal
strength');
max(v51);
find(v51 == 1); %% find the value of signal 1
lag51(find(v51==1)); % find the lag value
%%% Signal 6
[v61,lag61]=xcorr(y6new,y1new); %% correlattion of signal 1 and 2
v61 = v61/max(v61);
figure;
%subplot (8,1,2)
plot(lag61,v61);
title ('Lag of my
voice [repeat Abrakakabra]#1 and # 6 ');
xlabel('time (sec)');
ylabel('signal
strength')
max(v61);
find(v61 == 1); %% find the value of signal 1
lag61(find(v61==1)); % find the lag value
%%% Signal 7
[v71,lag71]=xcorr(y7new,y1new); %% correlattion of signal 1 and 2
v71 = v71/max(v71);
figure
plot(lag71,v71)
title ('Lag of my
voice [repeat Abrakakabra]#1 and # 7 ')
xlabel('time (sec)');
ylabel('signal
strength')
max(v71)
find(v71 == 1) %% find the value of signal 1
lag71(find(v71==1)) % find the lag value
%%% Signal 8
[v81,lag81]=xcorr(y8new,y1new); %% correlattion of signal 1 and 2
v81 = v81/max(v81);
figure
%subplot (8,1,3)
plot(lag81,v81)
title ('Lag of my voice [repeat Abrakakabra]#1 and # 8 ')
xlabel('time (sec)');
ylabel('signal
strength')
max(v81)
find(v81 == 1) %% find the value of signal 1
lag81(find(v81==1)) % find the lag value
%%% Signal 9
[v91,lag91]=xcorr(y9new,y1new); %% correlattion of signal 1 and 2
v91 = v91/max(v81);
figure
%subplot (9,1,1)
plot(lag91,v91)
title ('Lag of my voice [repeat Abrakakabra]#1 and # 9 ')
xlabel('time (sec)');
ylabel('signal
strength')
max(v91)
find(v91 == 1) %% find the value of signal 1
lag91(find(v91==1)) % find the lag value
%%% Signal 10
[v101,lag101]=xcorr(y10new,y1new); %% correlattion of signal 1 and 2
v101 = v101/max(v101);
figure
%subplot (9,1,2)
plot(lag101,v101)
title ('Lag of my voice [repeat Abrakakabra]#1 and # 10 ')
xlabel('time (sec)');
ylabel('signal
strength')
max(v101)
find(v101 == 1) %% find the value of signal 1
lag101(find(v101==1)) % find the lag value
%% Shift signal 2 to the
right
figure;
vshift = circshift (y2new,
-41806);
plot(vshift)
hold on
plot(y1new,'r')
l1=length (y1new); %% find
the length of signal 1
l2=length (vshift); %% find
the lenght of signal 2 where you shift
%vshift(1: 229364); %% cut
the signal to the smallest values
title ('shift of
voice [repeat Abrakakabra]#2 ')
xlabel('time (sec)');
ylabel('signal
strength');
figure;
plot (y1new)
hold on
vshiftcut = vshift(1: 229364);
figure
plot(vshiftcut, 'g')
%plot(y1new,'g')
title ('cut the shift
signal of voice [repeat Abrakakabra]#2 ')
xlabel('time (sec)');
ylabel('signal
strength')
%meanvshiftnew =
mean(vshiftcut,y1new); %% take the mean of 2 signal wrong
%still in 1D or values
meanvshiftnew =
mean([vshiftcut,y1new],2); %% correct need to 2D
figure
plot (meanvshiftnew)
title ('plot average
of my voice [repeat Abrakakabra]')
xlabel('time (sec)');
ylabel('signal
strength')
soundsc(meanvshiftnew, 44100)
%% Shift signal3 to the
right
figure
vshift2 = circshift (y3new,
41806);
%subplot (10,1,1)
plot(vshift2)
hold on
plot(y1new,'r')
title ('shift of
voice [repeat Abrakakabra]#3 ')
xlabel('time (sec)');
ylabel('signal
strength');
l3 = length (vshift2); %% find
the lenght of signal 2 where you shift
vshift2(1: 229364); %% cut the
signal to the smallest values
%figure
%subplot (10,1,2);
%%plot (vshift2);
%%hold on;
%plot (y1new, 'g');
vshiftcut2 = vshift2(1: 169961);
figure
%subplot (10,1,3);
plot(vshiftcut2);
hold on;
plot(y1new,'g');
title ('cut the shift
of voice [repeat Abrakakabra]#3 ');
xlabel('time (sec)');
ylabel('signal
strength')
%% Shift signal4 to the
right
figure
vshift4 = circshift (y4new,
-41806);
plot(vshift4)
hold on
plot(y1new,'r')
length (vshift4) %% find
the lenght of signal 2 where you shift
%vshift4(1: 169961); %% cut
the signal to the smallest values
title ('shift of
voice [repeat Abrakakabra]#4 ')
xlabel('time (sec)');
ylabel('signal
strength')
%figure
%plot (vshift4)
%hold on
%plot (y1new, 'g')
vshiftcut4 = vshift4(1: 169961);
figure
plot(vshiftcut4)
hold on
plot(y1new,'g')
title ('cut shift of
voice [repeat Abrakakabra]#4 ')
xlabel('time (sec)');
ylabel('signal
strength')
%% Shift signal 5 to the
right
figure
vshift5 = circshift (y5new,
-366232);
plot(vshift5)
hold
hold on
plot(y1new,'r')
l5=length (vshift5); %% find
the lenght of signal 2 where you shift
vshift5(1: 229364); %% cut the
signal to the smallest values
title ('shift of
voice [repeat Abrakakabra]#5 ')
xlabel('time (sec)');
ylabel('signal strength')
%figure
%plot (vshift5)
%hold on
%plot (y1new, 'g')
%title ('voice [repeat
Abrakakabra]#5 ')
%xlabel('time (sec)');
%ylabel('signal strength')
vshiftcut5 = vshift5(1: 169961);
figure
plot(vshiftcut5)
hold on
plot(y1new,'g')
title ('cut shift of
voice [repeat Abrakakabra]#5 ')
xlabel('time (sec)');
ylabel('signal
strength')
%% Shift signal6 to the
right
figure
vshift6 = circshift (y6new,
241624); %%OK
plot(vshift6)
hold on
plot(y1new,'r')
l6 =length (vshift6) %% find
the lenght of signal 2 where you shift
vshift6(1: 229364); %% cut the
signal to the smallest values
title ('shift of
voice [repeat Abrakakabra]#6 ')
xlabel('time (sec)');
ylabel('signal
strength')
figure
plot (y1new, 'g')
hold on
vshiftcut6 = vshift6(1: 169961);
plot(vshiftcut6)
title ('cut shift of
voice [repeat Abrakakabra]#6 ')
xlabel('time (sec)');
ylabel('signal
strength')
%% Shift signal 7 to the
left
figure
vshift7 = circshift (y7new,
-333099);
plot(vshift7)
hold on
plot(y1new,'r');
l7=length (vshift7) %% find
the lenght of signal 2 where you shift
vshift7(1: 229364); %% cut the
signal to the smallest values'
title ('shift of
voice [repeat Abrakakabra]#7 ')
xlabel('time (sec)');
ylabel('signal
strength')
figure
plot (y1new, 'g')
hold on
vshiftcut7 = vshift7(1: 169961);
plot(vshiftcut7)
title ('cut shift of
voice [repeat Abrakakabra]#7 ')
xlabel('time (sec)');
ylabel('signal
strength')
%% Shift signal 8 to the
left
figure
vshift8 = circshift (y8new,
-670333);
plot(vshift8);
hold on
plot(y1new,'r');
l8=length (vshift8); %% find
the lenght of signal 2 where you shift
%%vshift8(1: 229364); %%
cut the signal to the smallest values
title ('shift of
voice [repeat Abrakakabra]#8 ');
xlabel('time (sec)');
ylabel('signal
strength');
figure
plot (y1new);
hold on;
vshiftcut8 = vshift8(1: 169961);
plot(vshiftcut8, 'g')
title ('cut line of
voice [repeat Abrakakabra]#8 ')
xlabel('time (sec)');
ylabel('signal
strength')
%% Shift signal 9 to the
left
figure
vshift9 = circshift (y9new, -179961);
plot(vshift9)
hold on
plot(y1new,'r')
l9=length (vshift9); %% find
the lenght of signal 2 where you shift
%vshift9(1: 169961); %% cut
the signal to the smallest values
title ('shift of
voice [repeat Abrakakabra]#9 ')
xlabel('time (sec)');
ylabel('signal
strength')
figure;
plot (y1new, 'r');
hold on;
vshiftcut9 = vshift9(1: 169961);
plot(vshiftcut9, 'r');
title ('cut line of
voice [repeat Abrakakabra]#9 ')
xlabel('time (sec)');
ylabel('signal
strength')
%% Shift signal10 to the
right
figure
vshift10 = circshift (y10new,
241624);
plot(vshift10)
hold on
plot(y1new,'r')
l10 =length (vshift10) %% find
the lenght of signal 2 where you shift
%vshift10(1: 169961); %%
cut the signal to the smallest values
title ('shift of
voice [repeat Abrakakabra]#10 ')
xlabel('time (sec)');
ylabel('signal
strength')
figure
plot (y1new, 'g')
hold on
vshiftcut10 = vshift10(1:
169961);
plot(vshiftcut10)
title ('cut shift of
voice [repeat Abrakakabra]#10 ')
xlabel('time (sec)');
ylabel('signal
strength')
figure
vshift1 = circshift (y1new,
20333);
plot(vshift1)
hold on
plot(y1new,'r')
vshift1(1: 169961); %% cut the
signal to the smallest values
title ('shift of
voice [repeat Abrakakabra]#1 ')
xlabel('time (sec)');
ylabel('signal
strength')
plot (y1new)
hold on
vshiftcut1 = vshift1(1: 169961);
figure
plot(vshiftcut1, 'r')
title ('cut line of
voice [repeat Abrakakabra]#1 ')
xlabel('time (sec)');
ylabel('signal
strength')
meanvshiftnewall =
mean([vshiftcut2,vshiftcut2, vshiftcut4, vshiftcut5, vshiftcut6, vshiftcut7,
vshiftcut8, vshiftcut9 ,vshiftcut1,y10new],2); %% correct need to 2D
figure
plot (meanvshiftnewall)
title ('plot average
of my voice [repeat Abrakakabra]')
xlabel('time (sec)');
ylabel('signal
strength')
soundsc(meanvshiftnewall, 44100)
%(ii) Plot the result of
the autocorrelation Rx[n]for each of
your 10 "abracadabra" %signals, as well as the average of the 10
autocorrelations. Also, plot the autocorrelation for the %averaged signal from
part (i) above, and compare and comment the two final plots.
%% do this for each signal
figure
subplot (4,2,1);
[acy1n,lagy1n] = xcorr(y1new,'coeff');
plot(lagy1n,acy1n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#1')
xlabel('time (sec)');
ylabel('signal
strength')
%figure;
subplot (4,2,2);
[acy2n,lagy2n] = xcorr(y2new,'coeff');
plot(lagy2n,acy2n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#2')
xlabel('time (sec)');
ylabel('signal
strength')
%figure;
subplot (4,2,3);
[acy3n,lagy3n] = xcorr(y3new,'coeff');
plot(lagy3n,acy3n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#3')
xlabel('time (sec)');
ylabel('signal
strength')
%figure;
subplot (4,2,4);
[acy4n,lagy4n] = xcorr(y4new,'coeff');
plot(lagy4n,acy4n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#4')
xlabel('time (sec)');
ylabel('signal
strength')
figure;
subplot (5,2,1);
[acy5n,lagy5n] = xcorr(y5new,'coeff');
plot(lagy5n,acy5n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#5')
xlabel('time (sec)');
ylabel('signal
strength')
%figure;
subplot (5,2,2);
[acy6n,lagy6n] = xcorr(y6new,'coeff');
plot(lagy6n,acy6n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#6')
xlabel('time (sec)');
ylabel('signal
strength')
figure;
subplot (5,2,3);
[acy7n,lagy7n] = xcorr(y7new,'coeff');
plot(lagy7n,acy7n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#7')
xlabel('time (sec)');
ylabel('signal
strength')
%figure;
subplot (5,2,4);
[acy8n,lagy8n] = xcorr(y8new,'coeff');
plot(lagy8n,acy8n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#8')
xlabel('time (sec)');
ylabel('signal
strength')
%figure;
subplot (6,2,1);
[acy9n,lagy9n] = xcorr(y9new,'coeff');
plot(lagy9n,acy9n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#9')
xlabel('time (sec)');
ylabel('signal
strength')
%figure;
subplot (6,2,2);
[acy10n,lagy10n] = xcorr(y10new,'coeff');
plot(lagy10n,acy10n)
xlim([0 200000])
title (' the
autocorrelation Rx[n]for my voice
[repeat Abrakakabra]#10')
xlabel('time (sec)');
ylabel('signal
strength')
l1 = length(acy1n);
l2 = length(acy2n);
l3 = length(acy3n);
l4 = length(acy4n);
l5 = length(acy5n);
l6 = length(acy6n);
l7 = length(acy7n);
l8 = length(acy8n);
l9 = length(acy9n);
l10 = length(acy10n);
%10 = length(acy10n);
cutsig1 = acy1n(1: 339921);
cutsig2 = acy2n(1: 339921);
cutsig3 = acy3n(1: 339921);
cutsig4 = acy4n(1: 339921);
cutsig5 = acy5n(1: 339921);
cutsig6 = acy6n(1: 339921);
cutsig7 = acy7n(1: 339921);
cutsig8 = acy8n(1: 339921);
cutsig9 = acy9n(1: 339921);
cutsig10 = acy10n(1: 339921);
mean1= mean([cutsig2,cutsig1,
cutsig3, cutsig4, cutsig5, cutsig6, cutsig7, cutsig8, cutsig9, cutsig10],2);
figure
plot (mean1);
title (' Average of
the autocorrelation Rx[n]for my voice ')
xlabel('time (sec)');
ylabel('signal
strength');
No comments:
Post a Comment