I want to generate a periodic trapezoidal wave that has 'ramps' on both sides of the wave structure. I was able to generate square waves that does not have ramps using the following codes.
Pwr_avg = 200;
nu_p = 2e3;
tau_p = 1/nu_p;
f_DC = 0.15;
tau_on = tau_p * f_DC;
tau_ramp = 1e-6;
Pwr_max = Pwr_avg * (tau_p/tau_on);
Pwr_min = 1e-4;
d = tau_on/2:tau_p:t_max;
Pwr = Pwr_max * pulstran(t_array,d,'rectpuls',tau_on);
Pwr(Pwr==0) = Pwr_min;
Pwr = Pwr / (pi*r_cyl^2*l_cyl) * 1e3;
The code above use pulse train function to generate periodic structure, which is used to simulate pulsed power. The absolute zero values for the power is not ideal for my application, so I assigned arbitrary small value when the power is 'off'.
Here, I would like to introduce a ramp up/down time as the power increases from zero, and decreases back to zero. So the pulsed waveform will become trapezoid that has steep ramps. I would like to know how to add ramps on this square wave or if Matlab already has inherent function I can use.
Thank you for your time