필터 지우기
필터 지우기

Trapezoidal pulse generation using gensig() function

조회 수: 5 (최근 30일)
Amit Kumar
Amit Kumar 2019년 10월 15일
답변: Praveen Iyyappan Valsala 2019년 10월 15일
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

채택된 답변

Praveen Iyyappan Valsala
Praveen Iyyappan Valsala 2019년 10월 15일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Pulse and Transition Metrics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by