write a matlb code that generates the following square pulse
write a matlb code that generates the following square pulse
Generate a periodic square wave with period T=1 ms. Plot its spectrum. Repeat for T=10^-4 sec, T=10^-6 sec and T=10^-9 sec. Explain your observations. 101010Solution
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]);
