Trapezoidal pulse generation using gensig() function

8 Ansichten (letzte 30 Tage)
Hi
I am trying to generate a trapezoidal pulse using gensig() function with rise time = fall time = 1s, time period = 5s, sampling time = 0.01s, and simulation time = 40s?
Is it possible to do so, since I can see only three options as 'sine', 'square' and 'pulse' when I studied about this fucntion in MATLAB help section.
Also kindly suggest if 'siggen()' is also some function in MATLAB or not?
Thanks

Akzeptierte Antwort

Praveen Iyyappan Valsala
Praveen Iyyappan Valsala am 15 Okt. 2019
The answer is No! .I am not aware of any function which can do that for you. Try to adapt my function for your needs or write your own.
%Does this work for you?
[t,p]=Trapezoidal_pulse(1,3,0.01,1,1,5,8);
figure,plot(t,p)
The function:
%%
function [t,pulse_train]=Trapezoidal_pulse(Amplitude,FlatTopTime,DwellTime,RiseTime,FallTime,DeadTime,Repetitions)
%[t,pulse_train]=Trapezoidal_pulse(Amplitude,FlatTopTime,DwellTime,RiseTime,FallTime,DeadTime,Repetitions)
% All times are of same units
% DwellTime-1/Sampling rate or raster time
% DeadTime- Dead Time after each pulse
%Repetitions -Number of Trapezoidal pulses
if(RiseTime<DwellTime)
warn('RiseTime<DwellTime: No Ramp up samples')
rampup_samples=[];
else
rampup_samples= linspace(0,Amplitude,ceil(RiseTime/DwellTime));
end
if(FallTime<DwellTime)
warn('FallTime<DwellTime: No Ramp down samples')
rampdown_samples=[];
else
rampdown_samples= linspace(Amplitude,0,ceil(FallTime/DwellTime));
end
pulse=[rampup_samples Amplitude*ones(1,ceil(FlatTopTime/DwellTime)) rampdown_samples zeros(1,ceil(DeadTime/DwellTime))];
%bipolar
% pulse_train=repmat(pulse,[Repetitions 1]).'.*(-1*ones(length(pulse),1)).^(0:Repetitions-1);
%unipolar
pulse_train=repmat(pulse,[Repetitions 1]).';
pulse_train=pulse_train(:);
%time
t=(0:(length(pulse_train)-1))*DwellTime;
end
Use doc or edit command to see the ownership and year at which the function is added to matlab.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by