Too many arguments error problem
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Utsav Panchal
am 9 Apr. 2021
Kommentiert: Utsav Panchal
am 9 Apr. 2021
This is my function 1:
function Speech_Recognition_Project(filename)
global voice;
voice=audioread(filename);
global x;
x=voice;
x=x';
x=x(1,:);
x=x';
m1 = Input_File('Input1.wav');
m2 = Input_File('Input2.wav');
m3 = Input_File('Input3.wav');
m4 = Input_File('Input4.wav');
m5 = Input_File('Input5.wav');
This is function 2:
function Input_File(filename)
global y;
y=audioread(filename);
y=y';
y=y(1,:);
y=y';
z=xcorr(x,y);
global m;
m=max(z);
l=length(z);
t=-((l-1)/2):1:((l-1)/2);
subplot(3,2,1);
plot(t,z);
I want value of m to stored in m1.
When I write Speech_Recognition_Project('Test.wav'). It shows me following error:
>> Speech_Recognition_Project('utsav.wav')
Error using Input_File
Too many output arguments.
Error in Speech_Recognition_Project (line 12)
m1 = Input_File('utsav.wav');
Please help me to figure out where I am going wrong.
0 Kommentare
Akzeptierte Antwort
DGM
am 9 Apr. 2021
Your function definition
function Input_File(filename)
specifies that this function takes one input argument and has zero output arguments. In order to get something out of it, you need to change your function definition to have an output argument. Consider the example:
function totallybig=biggerthanfive(inputnumber)
totallybig=(inputnumber>5);
end
The output argument 'totallybig' is in the function definition, and somewhere in the scope of the function, a value is assigned to it.
That's how you handle basic sharing of variables. Avoid using globals for everything ... or anything. If you need things within another function, pass them as arguments.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!