Creating a rectangular pulse

132 ビュー (過去 30 日間)
captainmariah
captainmariah 2017 年 10 月 12 日
回答済み: ahmed khouaja 2021 年 11 月 26 日
I can create an rectangular pulse with code
b1 = 5;
a1 = 5;
x = -10:0.01:10;
% a pulse function
f = @(xi,a,b) a*rectpuls(xi,b);
% plot to
plot(x,f(x,a1,b1),'b--');
title(['Rectangular Pulse']);
xlabel('Time');
ylabel('Amplitude');
I now want to move this pulse, to start from x = -2 and end at x=+3, i.e. not have it centred around zero?
Any idea how to make it so?

採用された回答

Mischa Kim
Mischa Kim 2017 年 10 月 12 日
captain, how about
plot(x,f(x-0.5,a1,b1),'b--');
  2 件のコメント
captainmariah
captainmariah 2017 年 10 月 12 日
Did not think about moving the x vector. Many thanks!
Elijah Uche
Elijah Uche 2020 年 10 月 20 日
Hi Mischa Kimm and Captain Mariah,
Please I need help with the fft of that rectangular pulse as well as its power spectral density
How do I also extract the bandwidth from the PSD?
Kindly assist, any hints/clues will be appreciated
Thanks
Elijah

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

その他の回答 (1 件)

ahmed khouaja
ahmed khouaja 2021 年 11 月 26 日
b1 = 5;
a1 = 5;
x = -10:0.01:10;
% a pulse function
f = @(xi,a,b) a*rectpuls(xi,b);
% plot to
plot(x,f(x,a1,b1),'b--');
title(['Rectangular Pulse']);
xlabel('Time');
ylabel('Amplitude');

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by