
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
- A die is thrown once. Find the probability of getting an even number or a number greater than 4.arrow_forwardThe following data shows the daily sales (in ₹1000) of a shop for 5 days: 8, 10, 6, 12, 14. Find the range and variance.arrow_forwardA bag contains 5 red balls and 3 blue balls. One ball is drawn at random. Find the probability that it is red.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 HillAlgebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal Littell
- Holt Mcdougal Larson Pre-algebra: Student Edition...AlgebraISBN:9780547587776Author:HOLT MCDOUGALPublisher:HOLT MCDOUGALTrigonometry (MindTap Course List)TrigonometryISBN:9781337278461Author:Ron LarsonPublisher:Cengage Learning





