commit 93bd705d1a875da33be95af289143438aae1cfd2 Author: Romain Murphy Date: Thu Oct 30 17:16:20 2025 +0100 Files diff --git a/ErrorPlot.m b/ErrorPlot.m new file mode 100644 index 0000000..d35bd6e --- /dev/null +++ b/ErrorPlot.m @@ -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') \ No newline at end of file diff --git a/Notes.m b/Notes.m new file mode 100644 index 0000000..67a0f8f --- /dev/null +++ b/Notes.m @@ -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) \ No newline at end of file diff --git a/Part3.slx b/Part3.slx new file mode 100644 index 0000000..a3e6c4e Binary files /dev/null and b/Part3.slx differ diff --git a/Part4.asv b/Part4.asv new file mode 100644 index 0000000..c4e59cb --- /dev/null +++ b/Part4.asv @@ -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) \ No newline at end of file diff --git a/Part4.m b/Part4.m new file mode 100644 index 0000000..43f5ea3 --- /dev/null +++ b/Part4.m @@ -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) \ No newline at end of file diff --git a/Part5.asv b/Part5.asv new file mode 100644 index 0000000..c45abbf --- /dev/null +++ b/Part5.asv @@ -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) \ No newline at end of file diff --git a/Part5.m b/Part5.m new file mode 100644 index 0000000..8d9fe14 --- /dev/null +++ b/Part5.m @@ -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) \ No newline at end of file diff --git a/Part6.m b/Part6.m new file mode 100644 index 0000000..3c8de92 --- /dev/null +++ b/Part6.m @@ -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'); \ No newline at end of file diff --git a/audioclip1-d4.wav b/audioclip1-d4.wav new file mode 100644 index 0000000..091d8ba Binary files /dev/null and b/audioclip1-d4.wav differ diff --git a/audioclip1-filt-d4.wav b/audioclip1-filt-d4.wav new file mode 100644 index 0000000..c0d76a4 Binary files /dev/null and b/audioclip1-filt-d4.wav differ diff --git a/audioclip1-filt.wav b/audioclip1-filt.wav new file mode 100644 index 0000000..d736e75 Binary files /dev/null and b/audioclip1-filt.wav differ diff --git a/audioclip1.wav b/audioclip1.wav new file mode 100644 index 0000000..abe76f4 Binary files /dev/null and b/audioclip1.wav differ diff --git a/echo_sound.m b/echo_sound.m new file mode 100644 index 0000000..ddf7659 --- /dev/null +++ b/echo_sound.m @@ -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. \ No newline at end of file diff --git a/lowpass2000_16k.m b/lowpass2000_16k.m new file mode 100644 index 0000000..7912800 --- /dev/null +++ b/lowpass2000_16k.m @@ -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 \ No newline at end of file diff --git a/part62.slx b/part62.slx new file mode 100644 index 0000000..dba77f5 Binary files /dev/null and b/part62.slx differ diff --git a/part62.slx.r2023b b/part62.slx.r2023b new file mode 100644 index 0000000..4a36dce Binary files /dev/null and b/part62.slx.r2023b differ