grzemot

Telekomunikacja_lab3_kwantowanie + zadanie w komentarzach

Nov 30th, 2019
670
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clear all; close all;
  2. [s,fp]=auload('bird.wav');
  3.  t1=length(s);
  4.  t=1:t1;
  5.  %subplot(2,2,1);
  6.  figure
  7.  plot(t,s(1:rows(s)),'-b');
  8.  amp=10.0;
  9.  s(1:rows(s))=amp*s(1:rows(s));
  10.  plot(t,s(1:rows(s)),'-b');
  11. n=4;
  12.  
  13.  % for n=1:10;
  14.  a=2^n-1;
  15.  sq=round(s(1:rows(s))*a)/a;
  16.  b=s(1:rows(s))-sq;
  17.  plot(t,s(1:rows(s)),'-b;Orginal signal;',t,sq,'-g;Sampled signal;',t,b,'-r;sampling error;');
  18.  grid ("on")
  19.  xlabel('time t');
  20.  ylabel('Amplitude A');
  21.  title('Quantization');
  22.  sb(n,:)=20*log10(std(s(1:rows(s)))/std(b));
  23.  print(['kw3nowysygnal',int2str(n),'.png'],"-dpng","-color");
  24.  sqq=round(s*a)/a;
  25.  ausave(['bird',int2str(n),'.wav'],sqq,fp);
  26.  %end
  27.  %subplot(2,2,3);
  28.  figure
  29.  plot(sb,'r*;Values of SNR;');
  30.  hold on;
  31.  plot(sb,'b-;;');
  32.  grid ("on");
  33.  hold off;
  34.  title('SNR on number of bits');
  35.  ylabel('Value of SNR [dB]');
  36.  xlabel('Number of bits [bit]');
  37.  n=[6 7 8 9 10];
  38.  polyfit(n',sb(6:10,:),1)
  39.  print("kw5reg.png","-dpng","-color");
  40.  subplot(2,2,2);
  41.  figure
  42.  plot(t,s(1:rows(s)),'-b');
  43.  s((1+rows(s)):(2*rows(s)))=amp*s((1+rows(s)):(2*rows(s)));
  44.  plot(t,s((1+rows(s)):(2*rows(s))),'-b');
  45.  %for n=1:10;
  46.  a=2^n-1;
  47.  sq=round(s((1+rows(s)):(2*rows(s)))*a)/a;
  48.  b=s((1+rows(s)):(2*rows(s)))-sq;
  49.  plot(t,s((1+rows(s)):(2*rows(s))),'-b;Orginal signal;',t,sq,'-g;Sampled signal;',t,b,'-r;sampling error;');
  50.  grid ("on")
  51.  xlabel('time t');
  52.  ylabel('Amplitude A');
  53.  title('Quantization');
  54.  sb(n,:)=20*log10(std(s((1+rows(s)):(2*rows(s))))/std(b));
  55.  print("kw3nowysygnal.png","-dpng","-color");  
  56.  %end
  57.  
  58.  %subplot(2,2,4);
  59.  figure
  60.  plot(sb,'r*;Values of SNR;');  %SNR signal to noise ratio
  61.  hold on;
  62.  plot(sb,'b-;;');
  63.  grid ("on");
  64.  hold off;
  65.  title('SNR on number of bits');
  66.  ylabel('Value of SNR [dB]');
  67.  xlabel('Number of bits [bit]');
  68.  n=[6 7 8 9 10];
  69.  polyfit(n',sb(6:10,:),1)
  70.  print("kw5reg.png","-dpng","-color");
  71.  % opracowac filtr ktory zredukuje szumy tak aby uzyc jak najmniej przetwornikow
  72.  % filtr powinien wygladzić wykres
  73.  %pojecia na zaliczenie filtracja, probkowanie, transformata fouriera, hilberta itd, podstawowe pojecia...
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×