OBJECT: Generation of a sinusoidal sequence with frequency of 3/20 Hz and to plot 50 samples (where sampling frequency is 1Hz). Assuming phase and amplitude to be entered by the user.
SOURCE CODE:
sample=50; frequency=3/20; amp=input('Enter the amplitude:'); phase=input('Enter the phase in degree:'); n=0:1:(sample-1); y=amp*sin(2*pi*frequency*n + phase); stem(n,y); xlabel('n'); ylabel('A M P L I T U D E '); title('S A M P L E D S I N E W A V E ASSIGN_1.1');
OUTPUT GRAPH:
Enter the amplitude:5
Enter the phase in degree:0
PROGRAM 2:
OBJECT: To generate a sinusoidal sequence with frequency of 4/20 Hz and plot 80 samples (where sampling frequency is 1Hz). Assuming phase and amplitude to be entered by the user.
SOURCE CODE:
sample=80; frequency=4/20; amp=input('Enter the amplitude:'); phase=input('Enter the phase in degree:'); n=0:1:(sample-1); y=amp*sin(2*pi*frequency*n + phase); /* PI IS A FUNCTION GIVING VALUE 3.14*/ stem(n,y); xlabel('n'); ylabel('A M P L I T U D E '); title('S A M P L E D S I N E W A V E ASSIGN_1.2');
OUTPUT GRAPH:
Enter the amplitude:5
Enter the phase in degree:30
PROGRAM 3:
OBJECT: To generate four sinusoidal sequence of phase shift of 0,70,130,180 and 360 and plot them together using "SUBPLOT" comment. (Where sampling frequency is 1Hz). Assuming amplitude to be entered by the user.
SOURCE CODE
sample=80; frequency=4/20; amp=input('Enter the amplitude:'); a=[0 70 130 180 360]; n=0:1:(sample-1); for i=1:5 y=amp*sin(2*pi*frequency*n+a(i)); stem(n,y); subplot(2,3,i) end xlabel('n'); ylabel('A M P L I T U D E '); title('S A M P L E D S I N E W A V E ASSIGN_1.3');
OUTPUT GRAPH:
PROGRAM 4:
OBJECT: To write a program to generate an exponential sequence K*(a^n) with a=0.8 and number of samples to be entered by the user. (Where sampling frequency is 1Hz). Assuming amplitude to be entered by the user.
SOURCE CODE:
sample=input('ENTER THE SAMPLES: '); k=input('Enter the value of K: '); a=0.8; n=0:1:sample-1; y= k*(a.^n); stem(n,y); xlabel('n'); ylabel('A M P L I T U D E'); title('EXPONENTIAL SEQUENCE');
OUTPUT GRAPH: For number of samples: 30 and K: 2
PROGRAM 5:
OBJECT: To generate a complex exponential sequences with C = (1/12) +( pi/12)*i. And repeat it for C = (1/12) +( pi/6)*i.(Where sampling frequency is 1Hz). Assuming amplitude to be entered by the user.
SOURCE CODE:
sample=input('ENTER THE SAMPLES: '); amplitude=input('Enter the value of amplitude: '); c=(1/12)+(pi/12)*i; n=0:1:sample-1; y= amplitude*exp(c*n); subplot(1,2,1); stem(n,imag(y)); subplot(1,2,2); stem(n,real(y)); xlabel('n'); ylabel('A M P L I T U D E'); title('EXPONENTIAL SEQUENCE');
OUTPUT GRAPH: For number of samples: 30 and amplitude: 1
PROGRAM 6:
OBJECT: To write a program to generate a saw-tooth sequence.
SOURCE CODE:
sample=input('ENTER THE SAMPLES: '); amplitude=input('Enter the value of amplitude: '); n=0:1:sample-1; y= amplitude*rem(n,10)/10; stem(n,y); xlabel('n'); ylabel('A M P L I T U D E'); title('SAW TOOTH SEQUENCE');
OUTPUT GRAPH: For number of samples: 50 and amplitude: 1
PROGRAM 7:
OBJECT: TO Write a program to generate a SQUARE WAVE sequence (UNIPOLAR).
SOURCE CODE:
sample=input('ENTER THE SAMPLES: '); ampli=input('Enter the value of amplitude: '); n=0:1:sample-1; y= ampli*rem((floor(n/10)),2); stem(n,y); xlabel('n'); ylabel('A M P L I T U D E'); title('SQUARE SEQUENCE');
OUTPUT GRAPH: For number of samples: 50 and amplitude: 1
Index of DSP Lab Manual.