Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Aim : Write a Mat Lab Program for generation of Basic sequences like Unit Impulse, Unit Step, Unit Ramp, Exponential, Sine and Cosine.
- %Program For Unit Impulse
- n=-2:2
- a=[zeros(1,2),ones(1,1),zeros(1,2)]
- subplot(3,2,1)
- stem(n,a)
- xlabel('n->')
- ylabel('Magnitude')
- title('Unit Impulse')
- %Program For Unit Step
- n=-2:2
- a=[zeros(1,2),ones(1,3)]
- subplot(3,2,2)
- stem(n,a)
- xlabel('n->')
- ylabel('Magnitude')
- title('Unit Step')
- %Program For Unit Ramp
- n=-2:3
- a=[zeros(1,2),0:3]
- subplot(3,2,3)
- stem(n,a)
- xlabel('n->')
- ylabel('Magnitude')
- title('Unit Ramp')
- %Program For Exponential
- n=0:10
- a=0.5
- ans=a.^m
- subplot(3,2,4)
- stem(n,ans)
- xlabel('n->')
- ylabel('Magnitude')
- title('Exponential')
- %Program For Sin
- n=-1:0.001:1
- a=sin(2*pi*n)
- subplot(3,2,5)
- plot(n,a)
- xlabel('n->')
- ylabel('Magnitude')
- title('Sine')
- %Program For Cos
- n=-1:0.001:1
- a=cos(2*pi*n)
- subplot(3,2,6)
- plot(n,a)
- xlabel('n->')
- ylabel('mag')
- title('Cosin')
- Aim : Write a Mat Lab Program to find convolution of two finite length Sequences.
- Program :
- % Program for Convolution
- u=input('Enter 1st Sequence : ');
- v=input('Enter 2nd Sequence : ');
- u1=length(u)
- v1=length(v)
- dpx=0:u1-1
- dph=0:v1-1
- subplot(2,2,1)
- stem(dpx,u)
- xlabel('n->')
- ylabel('Magnitude')
- title('1st Sequence')
- subplot(2,2,2)
- stem(dph,v)
- xlabel('n->')
- ylabel('Magnitude')
- title('2nd Sequence')
- y=conv(u,v)
- dpy=0:(u1+v1-2)
- subplot(2,2,[3,4])
- stem(dpy,y)
- xlabel('n->')
- ylabel('Magnitude')
- title('Convolution')
- Aim : Write a Mat Lab Program to verify the properties of Z – Transform.
- i. Linearity
- ii. Scaling in Z Domain
- iii. Time Reversal
- iv. Differential in Z- Domain
- Program :
- % Program for Linearity
- syms n
- f= 2^n
- ztrans(f)
- g= 3^n
- ztrans(g)
- x=f+g
- ztrans(x)
- % Program for Scaling in Z Domain
- syms a n w
- x1=(a^n)*cos(w.*n)
- ztrans(x1)
- % Program for Time Reversal
- syms a n
- x2= (a^(-n))
- ztrans(x2)
- % Program for Differential in Z Domain
- syms a n
- x3=n.*(a^n)
- ztrans(x3)
- Aim: Write a MATLAB program to design a low pas FIR filter using rectangular window.
- Program:
- %Program to design a Low Pass FIR Filter using rectangular window
- %Taking Input
- rp =input('Enter Pass Band Ripple : ')
- rs=input('Enter Stop Band Ripple : ')
- fp=input('Enter Pass Band Frequency : ')
- fs=input('Enter Stop Band Frequency : ')
- f=input('Enter Sampling Frequency : ')
- %Calculating Order
- wp=(2*fp)/f
- num= -20*log10(sqrt(rp*rs))
- den=14.6*(fs-fp)/f
- n=ceil(num/den)
- n1=n+1
- %Odd value
- if(rem(n,2)~=0)
- n1=n
- n=n+1
- end
- %Low Pass FIR Filter
- y=rectwin(n1)
- b=fir1(n,wp,y)
- [h,o]=freqz(b,1,256)
- m=20*log10(abs(h))
- %Plotting Values
- plot(o/pi,m)
- xlabel('Normalized Frequency')
- ylabel('Gain in DB')
Add Comment
Please, Sign In to add comment