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.

 採用された回答

DGM
DGM 2021 年 4 月 9 日

1 投票

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.

1 件のコメント

Utsav Panchal
Utsav Panchal 2021 年 4 月 9 日
Thanks a ton from our whole team!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Audio Plugin Creation and Hosting についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by