필터 지우기
필터 지우기

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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by