Clear Filters
Clear Filters

Creating a linear array of pulses

1 view (last 30 days)
Andy
Andy on 16 Jun 2023
Commented: Mathieu NOE on 16 Jun 2023
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
  2 Comments
Andy
Andy on 16 Jun 2023
Thanks Mathieu, that looks pretty much like the above diagram.

Sign in to comment.

Accepted Answer

Mathieu NOE
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
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]);

Sign in to comment.

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!