sinusoid with amplitude , frequency, samples, and sampling frequency?

how can i generate a sinusoid with amplitude 0.1 , frequency 100 Hz, with 100,000 samples, and sampling frequency 22,050 HZ? Please can anyone help me? thank you

 採用された回答

Image Analyst
Image Analyst 2018 年 5 月 26 日

0 投票

Did you try this?
amplitude = 0.1;
frequency = 100 % Hz
numSamples = 100000 % samples
samplingFrequency = 22050 % Hz (per second)
numSeconds = numSamples / samplingFrequency
x = linspace(0, numSeconds, numSamples);
y = amplitude * sin(2 * pi * x * frequency);
plot(x, y, 'b-', 'LineWidth', 2);
grid on;
xlabel('X', 'FontSize', 15);
ylabel('Y', 'FontSize', 15);

5 件のコメント

john khnayzir
john khnayzir 2018 年 5 月 26 日
thank you very much, but when i save the signal in a .wav file , i do not have any tone.
john khnayzir
john khnayzir 2018 年 5 月 26 日
wavwrite(y',"script.wav")
Image Analyst
Image Analyst 2018 年 5 月 26 日
編集済み: Image Analyst 2018 年 5 月 26 日
I hear something. Add this to the end of your code and turn up your speakers:
soundsc(y, samplingFrequency);
Also see attached demo on making a wav file.
john khnayzir
john khnayzir 2018 年 5 月 27 日
thank you very much, it is working. and how can i plot the spectrum of the signal? the signal is on the file.
Image Analyst
Image Analyst 2018 年 5 月 27 日
Call fft() or pwelch() followed by plot(), or call spectrogram().

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

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by