フィルターのクリア

Sine wave signal stop time

2 ビュー (過去 30 日間)
John Smith
John Smith 2015 年 5 月 3 日
コメント済み: John Smith 2015 年 5 月 3 日
Hi all,
I am generating a sine wave as shown below:
Fs = 8000;
dt = 1/Fs;
t = 0: dt: 3;
Fc = 320; % hertz
x1 = sin(2*pi*Fc*t);
plot(t,x1);
How can I make the sine wave stop after 2 seconds please?
  2 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 5 月 3 日
John - please clarify what you mean by wanting to make the sine wave stop after 2 seconds. Do you only want to show 2 seconds of data, and if so, then just initialize t as
t = 0:dt:2-dt;
John Smith
John Smith 2015 年 5 月 3 日
Thanks for the reply. I want the graph to show a time period of 3 seconds but the sine wave to start from 0sec and stop at 2 sec. How can I achieve this please?

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

採用された回答

Geoff Hayes
Geoff Hayes 2015 年 5 月 3 日
John - just do as before but specify t as
t = 0: dt: 2-dt;
Once you have called
plot(t,x1);
you will see data from 0 to 2 seconds. To extend this to 3 seconds, just change the x-axis limits using
xlim([0 3])
You will now have a time period from 0 to 3 seconds, but data for just 0 to 2.
  1 件のコメント
John Smith
John Smith 2015 年 5 月 3 日
Thanks for the reply.

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

その他の回答 (1 件)

KL
KL 2015 年 5 月 3 日
Fs = 8000;
dt = 1/Fs;
t1 = 0: dt: 2;
t2 = 0*(2: dt : 3);
t = [t1 t2];
Fc = 320; % hertz
x1 = sin(2*pi*Fc*t);
plot(t,x1);
is this what you want?

カテゴリ

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