Advertisement
szymcio93

townini

Oct 14th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1.  
  2.  
  3. pierwsze:
  4. H=zeros(63,32)
  5.  
  6. for i=1:32
  7. H(i:31+i,i)=h // wype³nienie wg wzoru Toeplitza, kolumnami
  8. end
  9.  
  10. a=[1:32]
  11. b=[1:32]
  12. c=[1:32]
  13.  
  14. a(2:31)=0 a=a'
  15.  
  16. b(1:32)=0
  17. b(2:3)=1
  18. b(4:5)=0.5
  19. b(6:7)=-1 b=b'
  20.  
  21. for i=0:31
  22. c(i+1)=sin(2*pi*2*i/32)+sin(2*pi*6*i/32) c=c'
  23. end
  24.  
  25. y1=H*a
  26. y2=H*b
  27. y3=H*c
  28.  
  29. TEST=zeros(63,2)
  30. TEST(1:32,1)=h
  31. TEST(1:63,2)=y1
  32.  
  33. hold all ?
  34. plot(b) ?
  35. plot(y2) ?
  36.  
  37. P=pinv(H)
  38. b_kor=P*y2 //zdekodowanie jest mozliwe
  39.  
  40.  
  41. YY=conv(h,c) //identico
  42.  
  43. freqz(h)
  44. freqz(c)
  45. freqz(y3)
  46.  
  47. -----------------------------------------------------------------------------
  48. DRUGIE:
  49.  
  50. for n=0:31
  51. for m=0:31
  52. F(n+1,m+1)=(1/sqrt(32))*cos((2*pi*n*m)/32)-j*(1/sqrt(32))*sin((2*pi*n*m)/32)
  53. end
  54. end
  55.  
  56. c(i+1)=sin(2*pi*2*i/32)+sin(2*pi*6*i/32)
  57. c=c'
  58. x=F*c
  59.  
  60. x_log = 20*log10(abs(x)) // zamiana na decybele
  61.  
  62. plo=F^-1*x // 1 sposob
  63.  
  64. FF=conj(F)
  65. FF=FF'
  66.  
  67. plo2=FF*x // 2 sposo
  68.  
  69. x ma byc duzy
  70.  
  71. --------------------------------------------------------------------------------------------------------
  72. TRZECIE:
  73.  
  74. d=rand(1,1024);
  75. d=round(d);
  76. plo=zeros(1,1024)
  77.  
  78.  
  79. for i=1:1024
  80. if i<10
  81. plo(i)=1
  82. else
  83.  
  84. if((d(i-9)==0)&&(d(i-4)==1))||((d(i-9)==1)&&(d(i-4)==0))
  85. plo(i)=1
  86. end
  87. end
  88. end
  89.  
  90. -------------------------------------------------------------------------------------
  91. CZWARTE:
  92.  
  93. #include <iostream>
  94. #include <cstdlib>
  95. #include <time.h>
  96. #include <iomanip>
  97. #include <cmath>
  98.  
  99. using namespace std;
  100.  
  101. int n=32*32;
  102. int N=sqrt(n);
  103.  
  104. void wypelnij(float A[])
  105. {
  106. for (int i=0;i<n;i++)
  107. A[i]=rand()%10;
  108. }
  109.  
  110. void rys (float A[])
  111. {
  112. for (int j=0;j<N;j++)
  113. {
  114. for (int i=0;i<N;i++)
  115. cout<<setw(3)<<A[2*j+i+j]<<" ";
  116. cout<<endl;
  117. }
  118. cout<<endl;
  119. }
  120.  
  121. void mnoz (float A[],float B[],float C[])
  122. {
  123. for (int i = 0; i < N; i++)
  124. for (int j = 0; j < N; j++) {
  125. C[i + j*N] = 0;
  126. for (int k = 0; k < N; k++)
  127. C[i + j*N] += A[i + k*N]*B[k + N*j];
  128. }
  129. }
  130.  
  131.  
  132.  
  133. int main()
  134. {
  135.  
  136.  
  137. srand(time(NULL));
  138. float A[n],B[n],C[n];
  139.  
  140. clock_t t;
  141. t = clock(); //start
  142.  
  143. for(int g=0;g<10000;g++)
  144. {
  145. wypelnij(A);
  146. wypelnij(B);
  147.  
  148. //rys(A);
  149. // rys(B);
  150. mnoz(A,B,C);
  151. // rys(C);
  152. }
  153.  
  154. t = clock() - t; //stop
  155. printf ("Liczba taktow %d (%f seconds).\n",t,((float)t)/CLOCKS_PER_SEC);
  156. return 0 ;
  157.  
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement