How to create a MATLAB code for generating audio sine wave signal of frequency ranges from 1Hz to 15kHz and plot it on real time.

13 ビュー (過去 30 日間)
I use MATLAB for Engineering computations for almost 3 years, however I don't have any idea how to "How to create a MATLAB code for generating audio sine wave signal of frequency ranges from 1Hz to 15kHz and plot it on real time." I request the staff to help me in generating this code.

回答 (2 件)

Geoff Hayes
Geoff Hayes 2021 年 9 月 28 日
Zafar - see the relevant parts of the noisy signal example on how to generate a sine wave with a particular frequency. You will need to determine how you transition between the different frequencies (or are they separate plots?) and what the "real time" component is.
  1 件のコメント
Zafar Ahmad
Zafar Ahmad 2021 年 9 月 29 日
Sir, the example 'noisy signal' is about creating signal and it's Fourier transform etc, I want an audio tune signal having frequency ranges from 1Hz to 15kHz.

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


jibrahim
jibrahim 2021 年 9 月 29 日
Zafar, you can achieve this with audioOscillator and timescope. Here is an example.
% Generate and visualize a sine wave with variable frequency
osc = audioOscillator('sine');
scope = timescope('SampleRate',osc.SampleRate,...
'TimeSpanSource','property','TimeSpan',0.1, ...
'YLimits',[-1.5 1.5],...
'Title','Variable-Frequency Sine Wave');
counter = 0;
while (counter < 1e4)
counter = counter + 1;
scope(osc());
if mod(counter,1000)==0
osc.Frequency = osc.Frequency + 50;
end
end
  2 件のコメント
Zafar Ahmad
Zafar Ahmad 2021 年 10 月 7 日
I tried using multiple approaches to feed (an audio tune signal genrated in the same code) to an audioOscillator, however it accepts by default it's own wave forms sine wave, square wave and saw tooth wave from. How I can feed my own audio tune signal to generate a dynamic wave from?
jibrahim
jibrahim 2021 年 10 月 7 日
編集済み: jibrahim 2021 年 10 月 7 日
Hi Zafar,
If you want to generate a periodic signal based on a custom wave, then I suggest you take a look at wavetableSynthesizer.
If your signal is a long MATLAB vector, and you want to stream it, you can pass it one frame at a time to the for loop. Something like this:
x = randn(1e6,1); % let's say this is your signal
frameLength = 1024;
counter = 1;
while (counter < floor(size(x,1)/frameLength))
frame = x((counter-1)*frameLength+1:counter*frameLength);
counter = counter + 1;
scope(frame);
end

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

カテゴリ

Help Center および File ExchangePulse and Transition Metrics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by