Having issues playing a simple tone with MATLAB.

10 visualizaciones (últimos 30 días)
Carlyle Hickman
Carlyle Hickman el 21 de Nov. de 2016
Comentada: Carlyle Hickman el 21 de Nov. de 2016
Here is my function:
function playtone(freq,sf,amplitude,duration)
%Plays a simple tone.
%freq = frequency of tone (in Hz).
%sf = sampling frequency (in Hz).
%amplitude = sound amplitude (dimensionless).
%duration = sound duration (in seconds).
t = 0:1/sf:duration;
sound_vector = amplitude*sin(2*pi*freq*t);
sound(sound_vector,sf)
.
.
.
.
.
.
.
.
.
Here are my values:
>> freq = 1000;
>> sf = 10000;
>> amplitude = 1;
>> duration = 10;

Respuestas (1)

Image Analyst
Image Analyst el 21 de Nov. de 2016
It works fine for me. Make sure your speakers are turned on, both on your computer, and on the speakers themselves.
  5 comentarios
Image Analyst
Image Analyst el 21 de Nov. de 2016
Did you save it as test2.m like I had it? If so, it should run. You must have changed the name of it when you saved it. Please attach your m-file with the paper clip icon.
Carlyle Hickman
Carlyle Hickman el 21 de Nov. de 2016
I did all of the above.

Iniciar sesión para comentar.

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by