Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % function y = filter_zad1(x)
- % b0 = 1;
- % b1 = 0;
- % b2 = 0;
- % a1 = 1;
- % a2 = 0;
- % y(1) = b0*x(1);
- % y(2) = b0*x(2) + b1*x(1) - a1*y(1);
- % for n = 3: length(x)
- % y(n) = b0*x(n) + b1*x(n-1) + b2*x(n-2) - a1*y(n-1) - a2*y(n-2);
- % end
- % end
- N = 64;
- X = linspace(0, N-1, N);
- imp = double(kroneckerDelta(sym(X)))';
- b = [1 0 0]
- a = [1 1 0]
- filteredImp = filter_zad1(imp)';
- stdFilteredImp = filter(b, a, imp);
- s = stem(filteredImp);
- title('Przetworzony sygnał impulsowy przez napisaną przez na funkcję');
- xlabel('Nr próbki'); ylabel('Ampituda');
- figure;
- s = stem(stdFilteredImp);
- title('Przetworzony sygnał impulsowy przez funkcję wbudowaną filter');
- xlabel('Nr próbki'); ylabel('Ampituda');
- [h, w] = freqz(filteredImp);
- figure;
- plot(w/pi, 20*log10(abs(h)))
- [phi, w] = phasez(filteredImp);
- figure;
- plot(w/pi, phi*180/pi);
- figure;
- plotyy(w/pi, 20*log10(abs(h)), w/pi, phi*180/pi);
- fvtool(b, a,'polezero');
- [bx,ax] = eqtflength(bf,af);
- [z,p,k] = tf2zp(bx,ax);
- text(real(z)+.1, imag(z), 'zero');
- text(real(p)+.1, imag(p), 'biegun');
- noise = wgn(N, 1, 0);
- figure;
- filteredNoise = filter(b, a, noise);
- stem([noise, filteredNoise]);
- figure;
- spec = abs(fft(noise));
- stem(spec);
- figure;
- filteredSpec = abs(fft(filteredNoise));
- stem(filteredSpec);
- figure;
- stem([spec filteredSpec]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement