フィルターのクリア

Random Non-periodic waveform

5 ビュー (過去 30 日間)
Muhammad Atif
Muhammad Atif 2020 年 4 月 7 日
コメント済み: Star Strider 2020 年 4 月 10 日
How can I draw this waveform, it is a non periodic signal with the intervals like this {[1.54,2.49], [4.97,5.88], [6.69,7.98], [8.05,8.25],[8.58,9.09], [10.48,10.86], [11.16,12.97], [14.51,15.24],[15.38,15.60], [17.20,17.74], [19.16,22.38], [23.69,23.73],[24.59,25.47], [25.59,26.22], [26.65,29.27]}, these intervals are the starting and ending pionts of shaded area.

採用された回答

Star Strider
Star Strider 2020 年 4 月 7 日
編集済み: Star Strider 2020 年 4 月 7 日
Try this:
C = {[1.54,2.49], [4.97,5.88], [6.69,7.98], [8.05,8.25],[8.58,9.09], [10.48,10.86], [11.16,12.97], [14.51,15.24],[15.38,15.60], [17.20,17.74], [19.16,22.38], [23.69,23.73],[24.59,25.47], [25.59,26.22], [26.65,29.27]};
figure
hold all
for k = 1:numel(C)
patch([C{k} flip(C{k})], [0 0 1 1], [1 1 1]*0.8, 'EdgeColor','none')
end
hold off
It reproduces the image you posted, so I will not re-post it here.
EDIT — Added pulse train plot.
To draw it as a pulse train:
figure
hold all
for k = 1:numel(C)
plot([[1 1]*C{k}(1) [1 1]*C{k}(2)], [0 1 1 0], 'k')
end
hold off
grid
.
  6 件のコメント
Muhammad Atif
Muhammad Atif 2020 年 4 月 8 日
Brother I just need to create a random non-periodic waveform looks like the reference picture
Star Strider
Star Strider 2020 年 4 月 8 日
I am still not certain what you want.
Try this:
N = 25; % Number Of Segments
g = rand(1,N);
b = rand(1,N);
C = mat2cell([cumsum(g+b); cumsum(g+b)-b]', ones(1,size(g,2)), 2);
figure
hold all
for k = 1:numel(C)
patch([C{k} flip(C{k})], [0 0 1 1], [1 1 1]*0.8, 'EdgeColor','none')
end
hold off
set(gca,'Layer','top', 'Box','on') % Put Axes On Top Of ‘patch’ Objects
legend('DoS')
figure
hold all
for k = 1:numel(C)
plot([[1 1]*C{k}(1) [1 1]*C{k}(2)], [0 1 1 0], 'k')
end
hold off
grid

サインインしてコメントする。

その他の回答 (1 件)

Muhammad Atif
Muhammad Atif 2020 年 4 月 10 日
Hi Sir,
Can I plot it by using ones and zeros function separately? I mean first define the duration for which it is one and then define the duration for which it is zero. After that add up them on the whole interval. Or any other method to do this, any loop(if-else) that can help to slove it more simply.
  1 件のコメント
Star Strider
Star Strider 2020 年 4 月 10 日
I do not understand what you want. The code I wrote is about as simple as I can create it, unless there is information about this that has so far not been posted. The loops are necessary because of the nature of the data. Each interval must be plotted individually in the patch call.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by