To convolve two discrete square pulses in MATLAB, you can use the conv function.
Here is an example of how to do it:
main.m619 chars26 lines
In this example, pulse1 and pulse2 are two square pulses represented as arrays of ones and zeros. You can modify the pulse shapes and lengths according to your needs. The conv function is then used to calculate the convolution of pulse1 and pulse2. Finally, the original pulses and the convolution result are plotted using the stem function.
Note that in order to visualize the square pulses and the convolution, I have used the subplot and stem functions to create a multi-plot figure.
gistlibby LogSnag