Please compile the function file function a=test(b,c,d), so that when the input parameters are 1~3, the output parameter is the mean value of the input parameters (a=b or a=(b+c)/2 or a =(b+c+d)/3). Please directly use the source code of the functio
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Please compile the function file function a=test(b,c,d), so that when the input parameters are 1~3, the output parameter is the mean value of the input parameters (a=b or a=(b+c)/2 or a =(b+c+d)/3). Please directly use the source code of the function file created in matlab to answer
function mean = average(a,b,c)
if nargin == 1, average = a
end
if nargin == 2, average = (a+b)/2
end
if nargin == 3, average = (a+b+c)/3
end
end
hello guys anyone can help me to correct me the code?
0 件のコメント
回答 (1 件)
Walter Roberson
2020 年 11 月 25 日
0 投票
Your output variable is named mean. You need to assign to that variable.
0 件のコメント
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!