generation of impulse sequences
3 次查看(过去 30 天)
显示 更早的评论
How can I generate 100 impulse sequence with various amplitude?I need to generate 5 period of these impulse sequences.
0 个评论
回答(2 个)
Ryan G
2012-7-31
If the pulse frequency is consistent you can use a pulse generator multiplied by a scheduled gain for each pulse. You could use a lookup table and set the input to change the gain with time utilize a counter based on rising edges to look them up.
The other option could be to pre-define the pulses in the workspace and use a from workspace block or an inport.
0 个评论
Azzi Abdelmalek
2012-7-31
编辑:Azzi Abdelmalek
2012-7-31
nb=100 % number of amplitudes, for better illustration,put nb=10;
n=5;ts=0.1 % ts sample tim
width=5; %width: width of the pulse=0:ts:(width-1)*ts
interval_0=15; % the interval where the signal is zero=(interval_0-1)*ts
y1=[ones(width,nb*n);zeros(interval_0,nb*n)];
amplitude=1:nb; %in this example amplitudes are 1,2,...nb
amp=bsxfun(@times, ones(nb,5),amplitude');
y2=bsxfun(@times, amp(:)',y1);plot(y2(:))
result=y2(:);t=0:ts:(length(result)-1)*ts;close;plot(t,result);
%if you want use it in simulink
tresult =[t;result'];save filname tresult
%and use a block "from file"
2 个评论
Azzi Abdelmalek
2012-8-1
% y2 is a matrix with (5+15)lines and (100*5)columns
% the first column contain 5 "1" multiplied by your first gain and 15
% zeros; the second column contain 5 "1" multipied by your second gain and
% 15 "zeros"., ... the hundredth column contains 5 "1" multiplied by your
% hendredth gain and 15 0. for column 101 , it's the same as column1, and so.;
% y2(:) allows to create one vector containiing all columns of y2
% for better illustration run a program for nb=10; and then check a matrix
% y(2).
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Pulsed Waveforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!