Engineering arrays zybooks problem

10 ビュー (過去 30 日間)
Nathan
Nathan 2022 年 9 月 15 日
回答済み: Souvik Das 2022 年 9 月 22 日
function dailyMaterialSum = MaterialSum (weightArray)
% Write a function that sums the elements of the weightArray
% and prints the result to 2 decimal points
dailyMaterialSum = fprintf ('%.2f',(MaterialSum (weightArray)))
end

採用された回答

Souvik Das
Souvik Das 2022 年 9 月 22 日
The code below sums up the elements of the array and displays the result upto 2 decimal places.
function dailyMaterialSum = MaterialSum (weightArray)
% Write a function that sums the elements of the weightArray
% and prints the result to 2 decimal points
dailyMaterialSum = sum(weightArray);
fprintf('%.2f',dailyMaterialSum);
end
Also please follow the link below for the round function which might be useful too.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by