Last active
November 7, 2017 03:08
-
-
Save sparksbat/ad51a2d8836120f59803ec4769b65920 to your computer and use it in GitHub Desktop.
ECE306L Lab 6 Stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear variables; | |
z = [ | |
(1/sqrt(2)) + i*(1/sqrt(2)); | |
(1/sqrt(2)) - i*(1/sqrt(2)); | |
-(1/sqrt(2)) + i*(1/sqrt(2)); | |
-(1/sqrt(2)) - i*(1/sqrt(2)); | |
i; | |
-i; | |
-1 | |
]; | |
p = zeros(size(z)); | |
b0 = 8; %Gain | |
labfunc6(z,p,b0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear variables; | |
z = [ | |
(1/sqrt(2)) + i*(1/sqrt(2)); | |
(1/sqrt(2)) - i*(1/sqrt(2)); | |
-(1/sqrt(2)) + i*(1/sqrt(2)); | |
-(1/sqrt(2)) - i*(1/sqrt(2)); | |
i; | |
-i; | |
1 | |
]; | |
p = zeros(size(z)); | |
b0 = 8; %Gain | |
labfunc6(z,p,b0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear variables; | |
z = [ | |
(1/sqrt(2)) + i*(1/sqrt(2)); | |
(1/sqrt(2)) - i*(1/sqrt(2)); | |
-(1/sqrt(2)) + i*(1/sqrt(2)); | |
-(1/sqrt(2)) - i*(1/sqrt(2)); | |
-1; | |
1 | |
]; | |
p = zeros(size(z)); | |
b0 = 4; %Gain | |
labfunc6(z,p,b0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear variables; | |
z = [ | |
(1/sqrt(2)) + i*(1/sqrt(2)); | |
(1/sqrt(2)) - i*(1/sqrt(2)); | |
-(1/sqrt(2)) + i*(1/sqrt(2)); | |
-(1/sqrt(2)) - i*(1/sqrt(2)); | |
i; | |
-i; | |
]; | |
p = zeros(size(z)); | |
b0 = 4; %Gain | |
labfunc6(z,p,b0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function labfunc6(z,p,k) | |
%LABFUNC6 it does 306L lab 6 for you | |
k = 1/k; | |
[x, Fs] = audioread('music.au'); | |
figure('Name','Plots'); | |
[b,a] = zp2tf(z, p, k); | |
y = filter(b, a, x); | |
subplot(1,2,1); | |
plot(x); | |
scale = max(abs(x)); | |
axis([0 length(x) -1*scale scale]); | |
hold on; | |
plot(y); | |
xlabel('Samples'); | |
ylabel('Value'); | |
legend('Original','Filtered'); | |
hold off | |
subplot(1,2,2); | |
X = fft(x, length(x)); | |
X(1) = 0; | |
X = X(1:round(length(X)/2)); | |
nfx = Fs * (0:length(x)-1)/length(x); | |
nfx = nfx(1:round(length(nfx)/2)); | |
Y = fft(y, length(y)); | |
Y(1) = 0; | |
Y = Y(1:round(length(Y)/2)); | |
nfy = Fs*(0:length(y)-1)/length(y); | |
nfy = nfy(1:round(length(nfy)/2)); | |
plot(nfx, abs(X)); | |
hold on | |
plot(nfy, abs(Y)); | |
xlabel('f [Hz]'); | |
ylabel('Magnitude of X(f), Y(f)'); | |
legend('Original','Filtered'); | |
figure('Name','Z-P Diagram'); | |
zplane(b,a); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment