Not enough input argumaents
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Hi, I am very new to matlab and I am getting that 'not enough input arguments when typing this.
function [sum]=add(x,y)
w=x+y;
disp(w);
end
0 件のコメント
回答 (2 件)
It depends on how you call this function, try to call if from the command window :
x = 1;
y = 2;
s = add(x,y);
And then you should get an error, think about how the sum variable is calculated.
madhan ravi
2019 年 7 月 9 日
編集済み: madhan ravi
2019 年 7 月 9 日
https://in.mathworks.com/help/matlab/ref/function.html - I suggest you to read it for better understanding and further usage
x = 5; % example values
y = 2;
Result = Add(x,y)
% simply call it
function w = Add(x,y) % save the function in a separate file named as Add.m , note the name of the file should be same as the function name
w=x+y;
disp(w); %% redundant
end
Note: Don't name variables which are in-built functions of MATLAB.
6 件のコメント
hayyan shaikh
2019 年 7 月 9 日
hayyan shaikh
2019 年 7 月 9 日
madhan ravi
2019 年 7 月 9 日
What's wrong with the code in the answer??
hayyan shaikh
2019 年 7 月 9 日
hayyan shaikh
2019 年 7 月 9 日
madhan ravi
2019 年 7 月 9 日
Clearly you need to know the basics of MATLAB
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


