MATLAB program for Squarewave signal Generation


Square Wave:

A square wave is a kind of non-sinusoidal waveform, most typically encountered in electronics and signal processing. An ideal square wave alternates regularly and instantaneously between two levels. Its stochastic counterpart is a two-state trajectory. Square waves are described in terms of period, frequency and amplitude.



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=-10:0.01:10;

y=a*square(f*t,dc);

stem(t,y);

axis([0 1 -2.2 2.2])



Output Waveform:

Enter the amplitude of the square wave A=1

Enter the frequency of the square wave F=3

enter the duty cycle of the wave Dc=50


No comments