Input Sequence using Linear Convolution

Posted by fasxxzczc on Wednesday 21 March 2012

 Output of  Input Sequence using Linear Convolution

Problem Statement :  Find the output of a given system for given input sequence using linear convolution

1:  //     Generation of Standard Sequences (Unit Sample, Unit Ramp, Unit Step)  
2:  #include<dos.h>  
3:  #include<graphics.h>  
4:  #include<math.h>  
5:  #include<iostream.h>  
6:  #include<stdio.h>  
7:  #include<conio.h>  
8:  #include<stdlib.h>  
9:  void draw_seq(int a,int choice)  //a is number of samples  
10:  {  
11:       int i,j,size;  
12:       size = getmaxx()/(2*a);  
13:       setcolor(15);  
14:       line(getmaxx()/2,0,getmaxx()/2,getmaxy());   //drawing axes  
15:       line(0,getmaxy()/2,getmaxx(),getmaxy()/2);  
16:       setcolor(14);  
17:       setfillstyle(SOLID_FILL,14);  
18:       for(i=-a;i<0;i++)               //     left part of origin  
19:            pieslice(getmaxx()/2+(i*size),getmaxy()/2,0,360,2);  
20:       switch(choice)  
21:       {  
22:            case 1 :  
23:                 outtextxy(getmaxx()/2-43,20,"UNIT - SAMPLE");  
24:                 for(i=0;i<=a;i++)  
25:                 {  
26:                      if(i==0)  
27:                      {  
28:                           pieslice(getmaxx()/2,getmaxy()/2-size,0,360,2);  
29:                           line(getmaxx()/2,getmaxy()/2-size,getmaxx()/2,getmaxy()/2);  
30:                      }  
31:                      else  
32:                           pieslice(getmaxx()/2+(i*size),getmaxy()/2,0,360,2);  
33:                 }  
34:                 break;  
35:            case 2 :  
36:                 outtextxy(getmaxx()/2-43,20,"UNIT - STEP");  
37:                 for(i=0;i<=a;i++)  
38:                 {  
39:                      pieslice(getmaxx()/2+(i*size),getmaxy()/2-size,0,360,2);  
40:                      line(getmaxx()/2+(i*size),getmaxy()/2,getmaxx()/2+(i*size),getmaxy()/2-size);  
41:                 }  
42:                 break;  
43:            case 3 :  
44:                 outtextxy(getmaxx()/2-43,20,"UNIT - RAMP");  
45:                 for(i=0;i<=a;i++)  
46:                 {    setfillstyle(SOLID_FILL,14);  
47:                      pieslice(getmaxx()/2+(i*size),getmaxy()/2-size-((i-1)*size),0,360,2);  
48:                      line(getmaxx()/2+(i*size),getmaxy()/2,getmaxx()/2+(i*size),getmaxy()/2-size-((i-1)*size));  
49:                 }  
50:                 break;  
51:       }  
52:       getch();  
53:  }  
54:  void main()  
55:  {  
56:       int gd=DETECT,gm;  
57:       int sample,choice;  
58:       while(1)  
59:       {  
60:       initgraph(&gd,&gm,"E:\\tc\\bgi");  
61:       cleardevice();  
62:       cout<<"\n\t\tGeneration of Standard Sequences\n\t1.Unit Sample";  
63:       cout<<"\n\t2.Unit Step\n\t3.Unit Ramp\n\t4.Exit";  
64:       setcolor(GREEN);  
65:       outtextxy(10,100,"Enter Ur Choice :");  
66:       gotoxy(32,7);  
67:       cin>>choice;  
68:       if(choice==4)  
69:            exit(0);  
70:       setcolor(GREEN);  
71:       outtextxy(10,120,"Enter Number of SAMPLE :");  
72:       gotoxy(32,8);  
73:       cin>>sample;  
74:       if(sample==0)  
75:       {     setcolor(14);  
76:            outtextxy(getmaxx()/2-150,getmaxy()/2-10,"No Graph Exists for ZERO Samples");  
77:       }  
78:       switch(choice)  
79:       {  
80:        case 1:  
81:            draw_seq(sample,1);  
82:            break;  
83:        case 2:  
84:            draw_seq(sample,2);  
85:            break;  
86:        case 3:  
87:            draw_seq(sample,3);  
88:            break;  
89:       }  
90:      }  
91:  }  

{ 0 comments... read them below or add one }

Post a Comment