f= input('enter the frequency in hertz of the sine wave')
t=0:.01:5
y=sin(2*pi*f*t)
subplot(2,2,1)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title('Sine wave by 1311977')
%Program to generate triangular waveform
n=input ('Enter the length of the sequence N= ')
t=0:.1:n
y=sawtooth(t,.5); %sawtooth with 50% duty cycle (triangular)
subplot(2,2,2)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title('Triangular waveform by 1311977')
%Program to generate a continuous time square wave
a=input('Enter the amplitude of the square wave A = ')
f= input('Enter the frequency of the square wave F = ')
dc=input('Enter the duty cycle of the wave DC = ')
f=f*2*pi
t=0:.01:1
y=a*square(f*t,dc)
subplot(2,2,3)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title('square waveform by 1311977')
No comments:
Post a Comment