Created
November 13, 2017 05:34
-
-
Save sparksbat/ce54fe0a5a8c9a3292706606c06211e3 to your computer and use it in GitHub Desktop.
ECE 306L Prelab 6
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; | |
prelab_nr = '1'; | |
z = [(1/sqrt(2)) + (j*(1/sqrt(2))); | |
(1/sqrt(2)) - (j*(1/sqrt(2))); | |
j; | |
-j; | |
-(1/sqrt(2)) + (j*(1/sqrt(2))); | |
-(1/sqrt(2)) - (j*(1/sqrt(2))); | |
-1]; | |
angle = 0; | |
theta_val = exp(j*angle); | |
poles = zeros(size(z)); | |
[b, a] = zp2tf(z, poles, 1); | |
numer_eval = polyval(b, theta_val); | |
denom_eval = polyval(a, theta_val); | |
b0 = denom_eval/numer_eval; | |
b0 = 1/b0; | |
transfer = tf(b, a); | |
transfer = transfer*b0; | |
figure('Name','Pole-Zero Plot'); | |
zplane(b,a); | |
set(gcf, 'PaperUnits', 'inches') | |
set(gcf, 'PaperPosition', [0 0 4 4]) | |
print(gcf,'-depsc2','-loose',strcat(prelab_nr, 'b.eps')); | |
[b,a] = eqtflength(b,a); | |
[z,p,k] = tf2zp(b,a) | |
%text(real(z)+.1,imag(z),'Zero') | |
%text(real(p)+.1,imag(p),'Pole') | |
figure('Name', 'Bode Diagram'); | |
bode(transfer); | |
set(gcf, 'PaperUnits', 'inches') | |
set(gcf, 'PaperPosition', [0 0 4 4]) | |
print(gcf,'-depsc2','-loose',strcat(prelab_nr, 'cd.eps')); | |
n = 0:0.1:20; | |
freq_20 = cos(2*pi*n/20); | |
freq_10 = cos(2*pi*n/10); | |
freq_5 = cos(2*pi*n/5); | |
filt_20 = filter(b, a, freq_20); | |
filt_10 = filter(b, a, freq_10); | |
filt_5 = filter(b, a, freq_5); | |
figure('Name', '1/20 Hz'); | |
plot(n,filt_20); | |
xlabel('Time (s)'); | |
ylabel('Amplitude'); | |
set(gcf, 'PaperUnits', 'inches') | |
set(gcf, 'PaperPosition', [0 0 4 4]) | |
print(gcf,'-depsc2','-loose',strcat(prelab_nr, 'g.eps')); | |
figure('Name', '1/10 Hz'); | |
plot(n,filt_10); | |
xlabel('Time (s)'); | |
ylabel('Amplitude'); | |
set(gcf, 'PaperUnits', 'inches') | |
set(gcf, 'PaperPosition', [0 0 4 4]) | |
print(gcf,'-depsc2','-loose',strcat(prelab_nr, 'h.eps')); | |
figure('Name', '1/5 Hz'); | |
plot(n,filt_5); | |
xlabel('Time (s)'); | |
ylabel('Amplitude'); | |
set(gcf, 'PaperUnits', 'inches') | |
set(gcf, 'PaperPosition', [0 0 4 4]) | |
print(gcf,'-depsc2','-loose',strcat(prelab_nr, 'i.eps')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment