Creating a linear array of pulses

1 次查看(过去 30 天)
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

采纳的回答

Mathieu NOE
Mathieu NOE 2023-6-16
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 个评论
Mathieu NOE
Mathieu NOE 2023-6-16
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]);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by