Not enough input arguments

1 回表示 (過去 30 日間)
bhargav mehar
bhargav mehar 2020 年 11 月 26 日
コメント済み: Ameer Hamza 2020 年 11 月 27 日
function x=man(V,VF,y,L,D)
x=(V+VF)*y/(L+D);
end
this is the simple function i defined and i am facing the error as shown shown in the attachment. I am not able to understand the fault can you please help me out.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 26 日
編集済み: Ameer Hamza 2020 年 11 月 26 日
In MATLAB, a vector is consider a single input. If you want to pass you input as vector then change your function like this
function x=man(in)
V = in(1);
VF = in(2);
y = in(3);
L = in(4);
D = in(5);
x=(V+VF)*y/(L+D);
end
and then call it like this
a = [1, 2, 3, 4, 5];
man(a)
But if you want to stick to the current definition, then the other option is to use cell array. For example, keep using your current definition of 'man' and run the following lines
a = {1, 2, 3, 4, 5};
man(a{:})
  2 件のコメント
bhargav mehar
bhargav mehar 2020 年 11 月 27 日
thank you mate.
Ameer Hamza
Ameer Hamza 2020 年 11 月 27 日
I am glad to be of help!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by