Create a Function using MATLAB

Hello, could you please go over the Problem #1 for me?

3 件のコメント

Steven Lord
Steven Lord 2017 年 11 月 30 日
If you show us what you've tried and describe what's not working or what you're unsure about we may be able to offer some guidance.
Myoungchul Hwang
Myoungchul Hwang 2017 年 11 月 30 日
編集済み: Walter Roberson 2017 年 11 月 30 日
function [area,perimeter] = calculateAreaPerimeter(length)
area = width*height;
perimeter = 4*length;
end
% Please enter the length in inches:
x = input('Enter the length in inches','s')
% Compute the area and perimeter of a square
a = length(5,'in')
b = length(10,'in')
c = length(7.5,'in')
function = length(5,'in')
area = width*height
perimeter = 4*Length
end
Mukul Rao
Mukul Rao 2017 年 12 月 4 日
Like Steve mentioned, what part of the script are you confused at? Looks like "calculateAreaPerimeter" looks fine, except that the height and width must be set to the input "length". Also, you retrieve the outputs from your function as follows :
%Area and perimeter when the square has a side of length 5 inches
[area_5,perimeter_5] = calculateAreaPerimeter(5)

回答 (0 件)

この質問は閉じられています。

質問済み:

2017 年 11 月 30 日

閉鎖済み:

2023 年 12 月 28 日

Community Treasure Hunt

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

Start Hunting!