Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write the code out in Matlab! Create a user defined function that has sca

ID: 2082605 • Letter: P

Question

Please write the code out in Matlab!

Create a user defined function that has scalar inputs of length "L", width "W", and height "H". The function needs to calculate both the surface area "SA" and volume "V" of the rectangle which has those dimensions. Build in a way to ensure that the values are all positive and that the maximum of any dimension is 250, if either of these is true set the SA=-1, and V-1. Name the function "rectangle". Solution function y = rect(x) %update the function definition line as described y = x; end

Explanation / Answer

First im giving the code to generate the function rectangle:

function[SA,VOL]=RECTANGLE(L,W,H)
SA=2*(L*H+L*W+W*H);
VOL=L*W*H;
end

now function calling:

%function calling
clc;
clear all;
close all;
L=input('enter the length of rectangle:');
W=input('enter the width of the rectangle:');
H=input('enter the height of the rectangle');
[SA,VOL]=RECTANGLE(L,W,H)


run this programme it will ask the value of L,W,H enter the value accrding to your wish it will show the value of surface area and volume of rectangle.thank you.