
Concept explainers
To write:
A

Answer to Problem 6.1P
Solution:
The function file is,
% MATLAB code to calculates and returns the perimeter and area of a rectangle.
%Function file.
function [perimeter, Area] = perimarea(len, Wid)
%put the input arguments as length and width and get the perimeter and area
%by using the function perimarea.
perimeter = 2*(len+Wid);
%define the variable perimeter.
Area = len*Wid;
%define the variable area.
end
% end of function
%The script file should be placed in the same folder.
Explanation of Solution
The formula for the area of the rectangle is given as,
Here, the length of the rectangle is
Substitute 10 for
The formula for the perimeter of the rectangle is given as,
Substitute 10 for
MATLAB Code:
clc
clear all
close all
% MATLAB code to calculates and returns the perimeter and area of a rectangle.
%Function file.
function [perimeter, Area] = perimarea(len, Wid)
%put the input arguments as length and width and get the perimeter and area
%by using the function perimarea.
perimeter = 2*(len+Wid);
%define the variable perimeter.
Area = len*Wid;
%define the variable area.
end
% end of function
%The script file should be placed in the same folder.
Save the MATLAB script with name, perimarea.m in the current folder. Execute the function by typing the function name at the command window to generate output.
Result:
The result is,
Therefore, the result is stated above.
Want to see more full solutions like this?
Chapter 6 Solutions
MATLAB: A Practical Introduction to Programming and Problem Solving
- The following data represent total ventilation measured in liters of air per minute per square meter of body area for two independent (and randomly chosen) samples. Analyze these data using the appropriate non-parametric hypothesis testarrow_forwardeach column represents before & after measurements on the same individual. Analyze with the appropriate non-parametric hypothesis test for a paired design.arrow_forwardShould you be confident in applying your regression equation to estimate the heart rate of a python at 35°C? Why or why not?arrow_forward
- Given your fitted regression line, what would be the residual for snake #5 (10 C)?arrow_forwardCalculate the 95% confidence interval around your estimate of r using Fisher’s z-transformation. In your final answer, make sure to back-transform to the original units.arrow_forwardCalculate Pearson’s correlation coefficient (r) between temperature and heart rate.arrow_forward
- Big Ideas Math A Bridge To Success Algebra 1: Stu...AlgebraISBN:9781680331141Author:HOUGHTON MIFFLIN HARCOURTPublisher:Houghton Mifflin HarcourtGlencoe Algebra 1, Student Edition, 9780079039897...AlgebraISBN:9780079039897Author:CarterPublisher:McGraw Hill

