フィルターのクリア

Need help with user made Functions and Sub functions.

2 ビュー (過去 30 日間)
Neil Lallkissoon
Neil Lallkissoon 2017 年 3 月 16 日
回答済み: GEEVARGHESE TITUS 2017 年 3 月 17 日
Create a function that finds the volume, surface area and perimeter of a rectangular prism of height h, width w and depth d.
It should use separate sub functions to calculate the volume, surface area and the perimeter. The main function should be called and three arguments should be passed as such: function_name(h,w,d).
I have this so far, but I need help. If anybody can help or point me in the right direction, it would be much appreciated. Thank you.

回答 (1 件)

GEEVARGHESE TITUS
GEEVARGHESE TITUS 2017 年 3 月 17 日
The assignment operations were not right, and have rectified the code. The invoking format was also not correct, as you require three arguments and the one you provided was a single variable with four values.
function [v,sa,p] = Rectangle(w,h,d)
v = volume(w,h,d);
sa = surface_area(w, h, d);
p = perimeter(w, h, d);
function v = volume(w, h, d)
v = w*h*d;
function sa = surface_area(w, h, d)
sa = 2*(w*d+h*d+h*w);
function p = perimeter(w, h, d)
p = 2*d + 2*w;
%to run the function use [v,sa,p] = Rectangle(1,2,3)

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by