sound will not play Mac Matlab 2018b

9 次查看(过去 30 天)
Hi there, I am working through a brilliant Udeny course in Matlab and am currently working on generating a sound but am finding that this session does not work, even though I have written exactly as specified (I think!)
frequencies = 5000; % Hz
duration = 1; % duration of the sound
amplitude = 1; % loudness
fs = 44100; % Sampling rate
T = 1 / fs ; % Time sampling period
t = 0:T:duration; % time vector
signal = amplitude * cos(2 * pi * frequencies * t);
sound(signal, fs)
Can anyone tell me where I'm going wrong please?
  9 个评论
Walter Roberson
Walter Roberson 2020-2-19
MATLAB Online is at
http://matlab.mathworks.com
Not all licenses have access to that, but current student licences do.
Tracey Rochester
Tracey Rochester 2020-2-20
Thank you everyone, I trashed my file, and then emptied it, and the sound is now playing.

请先登录,再进行评论。

采纳的回答

Ajay Pattassery
Ajay Pattassery 2020-2-20
编辑:Ajay Pattassery 2020-2-20
The issue is most likey due to having multiple user-defined sound.m files.
Replace sound(signal, fs) with the following code
player = audioplayer(signal,fs);
play(player)
If it is playing for the above code, execute the following line
which -all sound
If it returns more than one sound.m location, rename all the sound.m files in location other than MATLAB builtin path which ends with toolbox\matlab\audiovideo\sound.m

更多回答(1 个)

Tracey Rochester
Tracey Rochester 2020-2-19
By the way, I'm running MATLAB R2018b, on a Mac, OS 10.14.6 Mojave...

类别

Help CenterFile Exchange 中查找有关 Code Generation and Deployment 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by