Samples in generating a given signal

10 ビュー (過去 30 日間)
Ara Liz
Ara Liz 2021 年 6 月 14 日
回答済み: Scott MacKenzie 2021 年 6 月 14 日
We have to generate 128 samples of sinusoid with frequency of 3000 Hz, amplitude of 0.8 and sampling rate is 8000 Hz. The correct codes were:
>> Fs = 8000;
>> t = [0:127]/Fs;
>> y = 0.8*sin(2*pi*3000*t);
>> plot(t,y);
I just want to know why is it 127 and not 128? Thank you so much in advance :)

回答 (1 件)

Scott MacKenzie
Scott MacKenzie 2021 年 6 月 14 日
There are 128 values in the vector [0:127]:
0, 1, 2, 3, ... 126, 127
If the vector was defined using the term 128, as in your question, there would be 129 terms:
0, 1, 2, 3, ... 127, 128

カテゴリ

Help Center および File ExchangeSignal Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by