Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pierwsze:
- H=zeros(63,32)
- for i=1:32
- H(i:31+i,i)=h // wype³nienie wg wzoru Toeplitza, kolumnami
- end
- a=[1:32]
- b=[1:32]
- c=[1:32]
- a(2:31)=0 a=a'
- b(1:32)=0
- b(2:3)=1
- b(4:5)=0.5
- b(6:7)=-1 b=b'
- for i=0:31
- c(i+1)=sin(2*pi*2*i/32)+sin(2*pi*6*i/32) c=c'
- end
- y1=H*a
- y2=H*b
- y3=H*c
- TEST=zeros(63,2)
- TEST(1:32,1)=h
- TEST(1:63,2)=y1
- hold all ?
- plot(b) ?
- plot(y2) ?
- P=pinv(H)
- b_kor=P*y2 //zdekodowanie jest mozliwe
- YY=conv(h,c) //identico
- freqz(h)
- freqz(c)
- freqz(y3)
- -----------------------------------------------------------------------------
- DRUGIE:
- for n=0:31
- for m=0:31
- F(n+1,m+1)=(1/sqrt(32))*cos((2*pi*n*m)/32)-j*(1/sqrt(32))*sin((2*pi*n*m)/32)
- end
- end
- c(i+1)=sin(2*pi*2*i/32)+sin(2*pi*6*i/32)
- c=c'
- x=F*c
- x_log = 20*log10(abs(x)) // zamiana na decybele
- plo=F^-1*x // 1 sposob
- FF=conj(F)
- FF=FF'
- plo2=FF*x // 2 sposo
- x ma byc duzy
- --------------------------------------------------------------------------------------------------------
- TRZECIE:
- d=rand(1,1024);
- d=round(d);
- plo=zeros(1,1024)
- for i=1:1024
- if i<10
- plo(i)=1
- else
- if((d(i-9)==0)&&(d(i-4)==1))||((d(i-9)==1)&&(d(i-4)==0))
- plo(i)=1
- end
- end
- end
- -------------------------------------------------------------------------------------
- CZWARTE:
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- int n=32*32;
- int N=sqrt(n);
- void wypelnij(float A[])
- {
- for (int i=0;i<n;i++)
- A[i]=rand()%10;
- }
- void rys (float A[])
- {
- for (int j=0;j<N;j++)
- {
- for (int i=0;i<N;i++)
- cout<<setw(3)<<A[2*j+i+j]<<" ";
- cout<<endl;
- }
- cout<<endl;
- }
- void mnoz (float A[],float B[],float C[])
- {
- for (int i = 0; i < N; i++)
- for (int j = 0; j < N; j++) {
- C[i + j*N] = 0;
- for (int k = 0; k < N; k++)
- C[i + j*N] += A[i + k*N]*B[k + N*j];
- }
- }
- int main()
- {
- srand(time(NULL));
- float A[n],B[n],C[n];
- clock_t t;
- t = clock(); //start
- for(int g=0;g<10000;g++)
- {
- wypelnij(A);
- wypelnij(B);
- //rys(A);
- // rys(B);
- mnoz(A,B,C);
- // rys(C);
- }
- t = clock() - t; //stop
- printf ("Liczba taktow %d (%f seconds).\n",t,((float)t)/CLOCKS_PER_SEC);
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement