MATLAB: How to plot a trapezoidal pulse in Matlab

pulsetrapezoid

I want to plot a trapezoidal pulse that has user defined rise time and fall time i.e. slope of the edges of the trapezoid can be set by me.

Best Answer

function [] = trapezoidal_pulse (rise_time, fall_time, height, length)
pulse = zeros (2, 4);
pulse(1,2)=height;
pulse(2,2)=rise_time;
pulse(1,3)=height;
pulse(2,3)=pulse(2,2)+length;
pulse(2,4)=pulse(2,3)+fall_time;
plot(pulse(2,:),pulse(1,:))
Related Question