Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all %czyszczenie pamięci
- clc %czyszczenie ekranu
- close all %zamknięcie wszystkich okien
- % Parametry sygnału
- fs = 16000;
- f = 8000;
- % Oryginalny
- ts = 0:1/20000:(2*pi*(1/f));
- s = sin(f*ts);
- t = 0:1/fs:(2*pi*(1/f));
- x = sin(f*t);
- % funkcja kwantowania
- Q1 = quantizer([8 1], 'float');
- X = quantize(Q1, x);
- X = compand(X,255,max(X),'mu/compressor');
- X_bit = num2bin(Q1,X);
- % Funkcja wprowadzająca błęy
- nr_bit = 1;
- for i = 1:length(X_bit)
- if(X_bit(i,nr_bit)=='1')
- X_bit(i,nr_bit) = '0';
- else
- X_bit(i,nr_bit) = '1';
- end
- end
- % Funkcja do odbierania sygnału
- Y_bit = bin2num(Q1,X_bit);
- %Ekspanser
- Y = compand(Y_bit,255,max(Y_bit),'mu/expander');
- Q2 = quantizer([13 1], 'float');
- y = quantize(Q1, Y);
- figure(1)
- stem(t,y)
- hold on
- plot(ts,s,'r') %Rysowanie funkcji
- xlabel('Czas [s]') %Oznaczenie osi X
- ylabel('Amplituda') %Oznaczenie osi Y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement