image thumbnail
from Continuous gate and Discrete gate by Nikhil Prathapani
Generation of Gate(Rectangular) wave in continuous and discrete time.

rect.m
clear all;
close all;
clc;
fs=500;
t=-5:1/fs:5;
x1=rectpuls(t,0.1);
subplot(2,1,1);
plot(t,x1);
axis([-0.2 0.2 -1.2 1.2]);
xlabel('time');
ylabel('amplitude');
title('continuous rectangular pulse');
subplot(2,1,2);
stem(t,x1);
axis([-0.2 0.2 -1.2 1.2]);
xlabel('number of samples');
ylabel('amplitude');
title('discrete rectangular pulse');
display(x1);

Contact us