Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic sound error in Matlab

Tags:

matlab

audio

I have the following Matlab function to produce a sound:

function [] = makesound( )

    cf = 2000;                  % carrier frequency (Hz)
    sf = 22050;                 % sample frequency (Hz)
    d = 1.0;                    % duration (s)
    n = sf * d;                 % number of samples
    s = (1:n) / sf;             % sound data preparation
    s = sin(2 * pi * cf * s);   % sinusoidal modulation
    sound(s, sf);               % sound presentation
    pause(d + 0.5);             % waiting for sound end

end

However when I run the code, I get the following error:

??? Error using ==> sound
Too many input arguments.

Error in ==> makesound at 14
sound(Beep,rate);

What is wrong?

like image 775
CodeGuy Avatar asked Nov 18 '25 01:11

CodeGuy


1 Answers

You probably have some function in your path, 'name hiding' a Matlab function. This function takes a smaller number of input arguments then Matlab's, therefore the Too many input arguments. In my case it was assert that caused the problem, in your case it could be anything. Walk step-by-step with the debugger (using F11 to jump into all functions you have along the way) till you find the place where some function fails. Then make sure the path where the problematic function sits, is at the bottom of Matlab's path list, so the default call is made to Matlab's function.

like image 60
Itamar Katz Avatar answered Nov 19 '25 20:11

Itamar Katz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!