File tree 1 file changed +42
-0
lines changed
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ // program to compute circular convolution of two sequences
2
+ #include <stdio.h>
3
+ int x [10 ],h [10 ],y [10 ];
4
+
5
+ main ()
6
+ { int i ,n ,k ,l1 ,l2 ,j ;
7
+ printf ("enter the length of the input sequence x(n)" );
8
+ scanf ("%d" ,& l1 );
9
+ printf ("enter the length of the input sequence h(n)" );
10
+ scanf ("%d" ,& l2 );
11
+ printf ("enter the input sequence x(n)" );
12
+ for (i = 0 ;i < l1 ;i ++ )
13
+ scanf ("%d" ,& x [i ]);
14
+ printf ("enter the input sequence h(n)" );
15
+ for (i = 0 ;i < l2 ;i ++ )
16
+ scanf ("%d" ,& h [i ]);
17
+ if (l1 < l2 )
18
+ { for (i = l1 ;i < l2 ;i ++ )
19
+ x [i ]= 0 ;
20
+ l1 = l2 ;
21
+ }
22
+ else
23
+ { for (i = l2 ;i < l1 ;i ++ )
24
+ h [i ]= 0 ;
25
+ }
26
+ for (n = 0 ;n < l1 ;n ++ )
27
+ { y [n ]= 0 ;
28
+ for (k = 0 ;k < l1 ;k ++ )
29
+ {if (k > n )
30
+ j = n - k + l1 ;
31
+ else
32
+ j = n - k ;
33
+ y [n ]= y [n ]+ x [k ]* h [j ];
34
+ }
35
+ }
36
+ printf ("output sequence y(n)\n" );
37
+ for (i = 0 ;i < l1 ;i ++ )
38
+ printf ("%d\t" ,y [i ]);
39
+ }
40
+
41
+
42
+
You can’t perform that action at this time.
0 commit comments