Can i use matlab to generate audio signals.

That means, i don't want to plot sin(wt), i want to make it audible in a easy way.

 Accepted Answer

This is the easiest way:
Fs = 14400; % Sampling Frequency
t = linspace(0, 1, Fs); % One Second Time Vector
w = 2*pi*1000; % Radian Value To Create 1kHz Tone
s = sin(w*t); % Create Tone
sound(s, Fs) % Produce Tone As Sound
For a detailed description of the functions in the most recent MATLAB releases, see the documentation for Audio Recording and Playback.

4 Comments

Sir , in order to hear it longer I am trying to increase 1 sec to 10 sec or more but it does not affect. What should I do for that?
Fs = 14400; % Sampling Frequency
secs = 10;
t = linspace(0, secs, Fs*secs+1); % Time Vector + 1 sample
t(end) = []; % remove extra sample
w = 2*pi*1000; % Radian Value To Create 1kHz Tone
s = sin(w*t); % Create Tone
sound(s, Fs) % Produce Tone As Sound
how to listen to 2 synthetic signals one after one
Fs = 14400; % Sampling Frequency
secs = 10;
t = linspace(0, secs, Fs*secs+1); % Time Vector + 1 sample
t(end) = []; % remove extra sample
w = 2*pi*1000; % Radian Value To Create 1kHz Tone
w2 = 2*pi*1440; % Radian Value To Create 1440 Hz Tone
s = sin(w*t); % Create Tone
s2 = sin(w2*t); % Create second Tone
sound([s, s2], Fs) % Produce Tone then second Tone As Sound

Sign in to comment.

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!