Files
This commit is contained in:
commit
93bd705d1a
|
|
@ -0,0 +1,15 @@
|
|||
close all
|
||||
clear all
|
||||
clc
|
||||
|
||||
out = sim("Part3.slx");
|
||||
|
||||
x = out.x.Data;
|
||||
|
||||
error = out.error;
|
||||
|
||||
plot(x,error);
|
||||
|
||||
xlabel('ADC input (Analog value) x');
|
||||
ylabel('Quantization error eq = xq* - x');
|
||||
title('Error graph for the 2-bit quantizer')
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
close all
|
||||
clear all
|
||||
clc
|
||||
|
||||
|
||||
fs = 2000;
|
||||
Ts = 1/fs;
|
||||
fi = [262;294;330;349;392;440;494;523];
|
||||
f2 = [262;262;262;294;330;294;262];
|
||||
G=[];
|
||||
for i = 1:7
|
||||
for t = i-1:Ts:i
|
||||
note = sin(2*pi*fi(i,1)*t);
|
||||
G=[G;note];
|
||||
end
|
||||
end
|
||||
|
||||
sound(G,fs)
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
close all
|
||||
clear all
|
||||
clc
|
||||
|
||||
Ts = 0.1;
|
||||
|
||||
%% 1
|
||||
num = [2 1];
|
||||
den = [1 2 1];
|
||||
|
||||
G = tf(num,den);
|
||||
|
||||
Gd = c2d(G,Ts)
|
||||
|
||||
[yc,tc] = step(G);
|
||||
[yd,td] = step(Gd);
|
||||
|
||||
plot(tc,yc);
|
||||
hold on
|
||||
plot(td,yd);
|
||||
hold on
|
||||
legend('continuous','discrete');
|
||||
title('Continuous and discrete step response')
|
||||
xlabel('time (s)')
|
||||
ylabel('amplitude (a.u.)')
|
||||
|
||||
|
||||
%% 2
|
||||
|
||||
num2 = [0.047 0.046];
|
||||
den2 = [1 -1.81 0.9];
|
||||
|
||||
Hd = tf(num2,den2,Ts)
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
close all
|
||||
clear all
|
||||
clc
|
||||
|
||||
Ts = 0.1;
|
||||
|
||||
%% 1
|
||||
% num = [2 1];
|
||||
% den = [1 2 1];
|
||||
%
|
||||
% G = tf(num,den)
|
||||
%
|
||||
% Gd = c2d(G,Ts)
|
||||
%
|
||||
% [yc,tc] = step(G);
|
||||
% [yd,td] = step(Gd);
|
||||
%
|
||||
% plot(tc,yc);
|
||||
% hold on
|
||||
% plot(td,yd);
|
||||
% hold on
|
||||
% legend('continuous','discrete');
|
||||
% title('Continuous and discrete step response')
|
||||
% xlabel('time (s)')
|
||||
% ylabel('amplitude (a.u.)')
|
||||
|
||||
|
||||
%% 2
|
||||
|
||||
num2 = [0.047 0.046];
|
||||
den2 = [1 -1.81 0.9];
|
||||
|
||||
Hd = tf(num2,den2,Ts);
|
||||
|
||||
Hdzpk = zpk(Hd);
|
||||
|
||||
pzmap(Hd);
|
||||
|
||||
pole(Hd)
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
close all
|
||||
clear all
|
||||
clc
|
||||
|
||||
num = [0 10];
|
||||
den = [0 0.1 1];
|
||||
|
||||
numfeed = [1 0];
|
||||
denfeed = [0 1 -1];
|
||||
|
||||
T1 = 0.1;
|
||||
T2 = 0.01;
|
||||
|
||||
feed = tf(numfeed,denfeed,-1)
|
||||
|
||||
H1 = c2d(tf(num,den),T1)
|
||||
H2 = c2d(tf(num,den),T2)
|
||||
|
||||
Hcl1 = feedback(H1,1)
|
||||
Hcl2 = feedback(H2,1)
|
||||
|
||||
pzmap(Hcl1)
|
||||
figure();
|
||||
pzmap(Hcl2)
|
||||
|
||||
Hcl1poles = pole(Hcl1)
|
||||
Hclpoles = pole(Hcl2)
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
close all
|
||||
clear all
|
||||
clc
|
||||
|
||||
num = [0 10];
|
||||
den = [0 0.1 1];
|
||||
|
||||
numfeed = [1 0];
|
||||
denfeed = [0 1 -1];
|
||||
|
||||
T1 = 0.1;
|
||||
T2 = 0.01;
|
||||
|
||||
feed = tf(numfeed,denfeed,-1)
|
||||
|
||||
H1 = c2d(tf(num,den),T1)
|
||||
H2 = c2d(tf(num,den),T2)
|
||||
|
||||
Hcl1 = feedback(H1,1)
|
||||
Hcl2 = feedback(H2,1)
|
||||
|
||||
pzmap(Hcl1)
|
||||
figure();
|
||||
pzmap(Hcl2)
|
||||
|
||||
Hcl1poles = pole(Hcl1)
|
||||
Hcl2poles = pole(Hcl2)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
clear all;
|
||||
close all;
|
||||
clc;
|
||||
[y, fs] = audioread ('audioclip1.wav');
|
||||
info = audioinfo ('audioclip1.wav');
|
||||
sound (y, fs) ;
|
||||
y4 = downsample (y, 4);
|
||||
sound (y4, fs/4) ;
|
||||
audiowrite('audioclip1-d4.wav', y4, fs/4) ;
|
||||
info_d4 = audioinfo('audioclip1-d4.wav');
|
||||
hd = lowpass2000_16k;
|
||||
fvtool(hd);
|
||||
yFilt = filter(hd, y);
|
||||
sound(yFilt, fs) ;
|
||||
audiowrite('audioclip1-filt.wav', yFilt, fs) ;
|
||||
info_filtred = audioinfo('audioclip1-filt.wav');
|
||||
yFilt4 = downsample (yFilt, 4);
|
||||
sound (yFilt4, fs/4);
|
||||
audiowrite('audioclip1-filt-d4.wav',yFilt4,fs/4);
|
||||
info_filt_down = audioinfo('audioclip1-filt-d4.wav');
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,11 @@
|
|||
clear all;close all; clc
|
||||
load handel; % the signal is y and sampling freq in Fs
|
||||
sound(y,Fs); pause(10); % Play the original sound
|
||||
alpha = 0.9; D = 4196; % Echo parameters
|
||||
b = [1,zeros(1,D),alpha]; % Filter parameters
|
||||
x = filter(b,1,y); % Generate sound plus its echo
|
||||
sound(x,Fs); % Play sound with echo
|
||||
%%=== Echo Removal
|
||||
pause(10);
|
||||
w = filter(1,b,x);
|
||||
sound(w,Fs); %The echo should no longer be audible.
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
function Hd = lowpass2000_16k
|
||||
Fs = 16000;
|
||||
Fpass = 2000;
|
||||
Fstop = 2200;
|
||||
Apass = 1;
|
||||
Astop = 80;
|
||||
|
||||
h = fdesign.lowpass(Fpass,Fstop,Apass,Astop,Fs);
|
||||
Hd = design(h,'equiripple');
|
||||
end
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue