square() function is used to generate the square wave.
%Program to generate a continuous time square wave
close all;
clear all;
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:.001:1;
y=a*square(f*t,dc);
plot(t,y);
axis([0 1 -2.2 2.2]);
%output
%Enter the amplitude of the square wave A = 2
%Enter the frequency of the square wave F = 10
%Enter the duty cycle of the wave DC = 50
%Program to generate a continuous time square wave
close all;
clear all;
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:.001:1;
y=a*square(f*t,dc);
plot(t,y);
axis([0 1 -2.2 2.2]);
%output
%Enter the amplitude of the square wave A = 2
%Enter the frequency of the square wave F = 10
%Enter the duty cycle of the wave DC = 50
No comments:
Post a Comment