Commit ad3375c5 authored by Umair Shahid's avatar Umair Shahid
Browse files

Add new file

parent b9e25779
----> RECODE & PLOT WORDS %
a1=audiorecorder(8000,8,1);
disp('Start speaking 1.') % RECORDING 'Umair' %
recordblocking(a1,2);
disp('Stop speaking 1.')
play(a1);
b = getaudiodata(a1);
subplot(2,1,1);
plot(b);
grid on;
ylabel('Amplitude')
title('word 1')
a2=audiorecorder(8000,8,1);
disp('Start speaking 2.') % RECORDING 'Shahid' %
recordblocking(a2,2);
disp('Stop speaking 2.')
play(a2);
c = getaudiodata(a2);
subplot(2,1,2);
plot(c);
grid on;
ylabel('Amplitude')
title('word 2')
figure
----> DURATION OF SIGNALS %
L1=length(b);
T1=L1/8000
dt = 1/8000;
t = dt*(0:L1-1)';
subplot(2,1,1);
plot(t,b);
ylabel('Amplitude')
xlabel('T(Sec)')
grid on;
title('Time in Seconds')
L2=length(c);
T2=L2/8000
dt = 1/8000;
t = dt*(0:L2-1)';
subplot(2,1,2);
plot(t,c);
ylabel('Amplitude')
xlabel('T(Sec)')
grid on;
title('Time in Seconds')
figure;
---> SAMPLING & RECONSTRUCTION %
Fs=1000; % Sampling Frequency %
Ts=1/Fs; % Sampling Period %
n=0:Ts:1; % TIME INDEX %
N=length(n); % NO'OF SAMPLE POINTS %
b;c; % ORIGINAL SIGNAL %
ta=0:0.001:1; % RECONSTRUCTION TIME %
y=zeros(N,length(ta)); % RECONSTRUCTION VECTOR %
for i=1:N
y1(i,:)=b(i)*rectpuls(Fs*ta-i+1);
y2(i,:)=c(i)*rectpuls(Fs*ta-i+1);
end
subplot(4,1,1)
plot(b)
grid on;
ylabel('Amplitude')
title('1st ORIGINAL SIGNAL ---> Umair');
subplot(4,1,2)
plot(ta,sum(y1))
grid on;
ylabel('Amplitude')
title('1st RECONSTRUCTED SIGNAL ---> Umair');
subplot(4,1,3)
plot(c)
grid on;
ylabel('Amplitude')
title('2nd ORIGINAL SIGNAL ---> Shahid');
subplot(4,1,4)
plot(ta,sum(y2))
grid on;
ylabel('Amplitude')
title('2nd RECONSTRUCTED SIGNAL ---> Shahid');
figure
----> FINDING FREQUENCIES AND PLOTTING %
d=fft(b);
subplot(2,1,1);
plot(abs(d));
grid on;
ylabel('Amplitude')
title('fft of word 1')
e=fft(c);
subplot(2,1,2);
plot(abs(e));
grid on;
ylabel('Amplitude')
title('fft of word 2')
figure
[maxValue,indexMax] = max(abs(fft(b-mean(b))));
frequency = (indexMax-1) * Fs / N;
number_of_cycles = frequency*Ts
datafft=fft(b);
datafft_abs=abs(datafft/N);
datafft_abs=datafft_abs(1:N/2+1);
f=Fs*(0:N/2)/N;
subplot(2,1,1);
plot(f,datafft_abs)
ylabel('Amplitude')
xlabel('f(Hz)')
grid on;
title('Frequency of Signal 1');
datafft=fft(c);
datafft_abs=abs(datafft/N);
datafft_abs=datafft_abs(1:N/2+1);
f=Fs*(0:N/2)/N;
subplot(2,1,2);
plot(f,datafft_abs)
ylabel('Amplitude')
xlabel('f(Hz)')
grid on;
title('Frequency of Signal 2');
figure;
CONVOLVING THE SIGNALS %
cov1=conv(b,b); % CONVLOVING 'Umair' SAME SIGNALS %
subplot(3,1,1)
plot(cov1);
grid on;
ylabel('Amplitude')
title('convolution b*b SAME SIGNAL')
cov2=conv(c,c); % CONVLOVING 'Shahid' SAME SIGNALS %
subplot(3,1,2);
plot(cov2);
grid on;
ylabel('Amplitude')
title('convolution c*c SAME SIGNAL')
cov3=conv(b,c); % CONVLOVING 'Umair & Shahid' SIGNALS %
subplot(3,1,3);
plot(cov3);
grid on;
ylabel('Amplitude')
title("convolution b*c Two SIGNALS");
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment