Creating a linear array of pulses
3 views (last 30 days)
Show older comments
Hi,
I'm hoping someone may know the answer to this.
I'm trying to replicate a timing sequence from a past project.
I have generated the pulses from the following code and plotted the results.
sldb = input('Enter the required desirable restlessness in db: ')
dc = chebwin(16,sldb);
n=1:16;
plot(x,dc,'Db','linewidth',5);
What I would like to do is arrange the data to look like the following (if possible).
Thanks in advance.
Andy
Accepted Answer
Mathieu NOE
on 16 Jun 2023
maybe this ?
I am not sure how you compute the "normalized on time " values so I tried something on my own :
h = dc(k)/sum(dc);
you can correct this with the right formula
n=16;
x = 1:n;
sldb = 30;
dc = chebwin(n,sldb);
figure(1)
plot(x,dc,'Db','linewidth',5);
figure(2)
for k = 1:n
h = dc(k)/sum(dc);
rectangle('Position',[k-0.5,(k-1)/n,1,h],'FaceColor',[0.58 0.82 0.98],'EdgeColor','b','LineWidth',2); % pos = [x y w h];
end
xlim([0.5 n+0.5]);
1 Comment
Mathieu NOE
on 16 Jun 2023
minor correction if you don't want the rectangles to touch each others
n=16;
x = 1:n;
sldb = 30;
dc = chebwin(n,sldb);
figure(1)
plot(x,dc,'Db','linewidth',5);
figure(2)
w = 0.75;
for k = 1:n
h = dc(k)/sum(dc);
rectangle('Position',[k-w/2,(k-1)/n,0.75,h],'FaceColor',[0.58 0.82 0.98],'EdgeColor','b','LineWidth',2); % pos = [x y w h];
end
xlim([0.5 n+0.5]);
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!