Created
November 23, 2010 12:27
-
-
Save teamon/711673 to your computer and use it in GitHub Desktop.
Teoria sygnalow, laboratorium nr 3
This file contains hidden or 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
Laboratorum nr 3 - 23.11.2010 - Probkowanie i kwantowanie | |
1. Probkowanie | |
sinus | |
a) fpr > 2*f | |
b) fpr == 2*f | |
c) fpr < f | |
Jak wyglada sygnal w dziedzinie czasu i czestotliwosci? | |
Wykres widma: | |
y = abs(fft(x)); | |
// policzyc os czestotliwosci f | |
plot(f,y); | |
// zamiast plot | |
semilogy(f,y) // skala y logarytmiczna | |
2. Kwantowanie | |
sinus, prostokat, trojkat | |
Jak sie zmienia w dziedzinie czasu i czestotliwosci? | |
Jak wyglada widmo sygnalu i bledu po kwantyzacji? | |
Wybrac trzy przypadki | |
Jak zmienia sie szum kwantyzacji? |
This file contains hidden or 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 [X] = fftg(x,fp) | |
% FFTG kresli wykres modulu widma sygnalu | |
% | |
% [X] = fftg(x,fp) | |
% x - sygnal, ktorego widmo ma zostac wykreslone | |
% fp - czestotliwosc z ktora sygnal zostal sprobkowany | |
% X - FFT sygnalu | |
% | |
% Podstawy i algorytmy przetwarzania sygnalow | |
% semestr letni 2005 | |
% | |
X = fft(x); | |
N = length(x); | |
dt = 1/fp; | |
df = 1 /(N*dt); | |
% bez przesuwania | |
%f = df*(0 : N-1); | |
%plot(f,abs(X),'r-'); | |
%semilogx(f,abs(X),'r-'); | |
% z przesuwaniem | |
f = ((1:N) - ceil(N/2)) /N/dt; | |
semilogy(f,fftshift(abs(X)),'r-'); | |
%semilogx(f,fftshift(abs(X)),'r-'); | |
legend('off') |
This file contains hidden or 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
% | |
% KW demonstruje kwantowanie sygnalu | |
% | |
% Podstawy i algorytmy przetwarzania sygnalow | |
% semestr letni 2005 | |
% | |
A=1; T=1; | |
t=0:.001:T; | |
% funkcja liniowa | |
s=(A/T)*t; | |
% funkcja kwadratowa | |
%s=t.^2; | |
% sinus | |
%s=0.5+0.5*sin(2*pi*t); | |
% szum o rozkladzie jednostajnym | |
%s=rand(1,1001); | |
% szum o rozkladzie normalnym | |
%s=randn(1,1001); s=s/max(abs(s)); s=(s/2)+0.5; | |
% subplot(111); clg; | |
for n=1:10; | |
a=2^n-1; | |
sq=round(s*a)/a; | |
b=s-sq; | |
plot(t,s,'-b;sygnal oryginalny;',t,sq,'-g;sygnal sprobkowany;',t,b,'-r;blad probkowania;'); grid on | |
xlabel('czas t'); ylabel('Amplituda A'); | |
title(['Kwantowanie sygnalu', num2str(n)]); | |
sb(n,:)=20*log10(std(s)/std(b)); | |
pause | |
end | |
pause | |
clf; plot(sb,'r*;wartosci SNR;'); hold on; | |
plot(sb,'b-;;'); grid on; | |
hold off; | |
title('Zaleznosc SNR od liczby bitow przetwornika'); | |
xlabel('Wartosc SNR [db]]'); | |
ylabel('liczba bitow przetwornika [bit]'); | |
n=[6 7 8 9 10]; | |
% wyznaczenie wspolczynnikow regresji | |
polyfit(n',sb(6:10,:),1) |
This file contains hidden or 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
F = 1000; | |
T = 1; | |
A = 1; | |
[t,y] = sinus(A, F, 20000, 0, T); | |
z = abs(fft(y)); | |
subplot(3,2,1); | |
plot(t(100:300),y(100:300)); | |
title("fpr = 20000"); | |
subplot(3,2,2); | |
fftg(y, 20000); | |
[t,y] = sinus(A, F, 2*F, 0, T); | |
z = abs(fft(y)); | |
subplot(3,2,3); | |
plot(t(100:200),y(100:200)); | |
title(["fpr = ", num2str(2*F)]); | |
subplot(3,2,4); | |
fftg(y, 20000); | |
[t,y] = sinus(A, F, F - 10, 0, T); | |
z = abs(fft(y)); | |
subplot(3,2,5); | |
plot(t(5:15),y(5:15)); | |
title(["fpr = ", num2str(F - 10)]); | |
subplot(3,2,6); | |
fftg(y, 990); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment