• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 258 pages
Exam (elaborations)

MATLAB for Engineers, 5th Edition – Complete Solution Manual (Chapters 2–6) with Code Examples

Document preview thumbnail
Preview 4 out of 258 pages

This comprehensive solution manual provides detailed, step-by-step MATLAB® code and explanations for homework problems from Chapters 2 through 6 of MATLAB for Engineers, 5th Edition. It includes solutions for foundational topics such as variable operations, array and matrix manipulation, plotting (2D, 3D, logarithmic, polar), function creation, symbolic math, numerical methods (interpolation, differentiation, integration), and data analysis. Each problem is accompanied by executable MATLAB scripts, tables, graphs, and annotations, making it an ideal resource for students, educators, and engineering professionals looking to verify solutions, learn MATLAB programming techniques, or prepare for exams.

Content preview

Matlab for Engineers, 5th Edition
Chapter 2 Homework Solutions

clear,clc, format shortg



You can either solve these problems in the command window, using MATLAB® as an electronic
calculator, or you can create an M-file of the solutions. If you are solving these problems as a homework
assignment or if you want to keep a record of your work, the best strategy is to use an M-file, divided
into cells with the cell divider %%.

Problem 2.1
Predict the outcome of the following MATLAB® calculations. Check your results by entering the
calculations into the command window.

1 + 3/4


ans = 1.75

5*6*4/2


ans = 60

5/2*6*4


ans = 60

5^2*3


ans = 75

5^(2*3)


ans = 15625

1 + 3 + 5/5 + 3 + 1

ans = 9

(1 + 3 + 5)/(5 + 3 + 1)


ans = 1



Using Variables

Problem 2.2
Identify which name in each of the following pairs is a legitimate MATLAB® variable name. Test your
answers by using isvarname—for example,

1

,isvarname fred

Remember, isvarname returns a 1 if the name is valid and a 0 if it is not. Although it is possible
to reassign a function name as a variable name, doing so is not a good idea. Use which to check
whether the preceding names are function names—for example,

which sin

In what case would MATLAB®tell you that sin is a variable name, not a function name?

The legitimate Matlab names are: fred book_1 Second_Place No_1 vel_5 tan

isvarname fred


ans = 1

isvarname book_1


ans = 1

isvarname Second_Place


ans = 1

isvarname No_1


ans = 1

isvarname vel_5


ans = 1

isvarname tan %although tan is a function name it can be used as a variable name


ans = 1

isvarname fred! %! is not an allowed character


ans = 0

isvarname book-1 % - is not an allowed character


ans = 0

isvarname 2ndplace %variable names must start with a letter


ans = 0

isvarname #1 %# is not an allowed character


ans = 0

isvarname vel.5 % . is not an allowed character


ans = 0
2

, isvarname while %while is a reserved name


ans = 0


which tan % tan is a function name


built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\elfun\@double\tan) % double method

which while %while is also a function name, but is reserved


built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\lang\while)


%You can reassign a function name as a variable name
%For example
sin=3


sin = 3

%The which function now tells us sin is a variable
which sin


sin is a variable.

% Use the clear function to return sin to its function definition
clear sin
which sin

built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\elfun\@double\sin) % double method



Scalar Operations and Order of Operations

Problem 2.3
Create MATLAB® code to perform the following calculations. Check your code by entering it into
MATLAB® and performing the calculations on your scientific calculator.

5^2


ans = 25

(5 + 3)/(5*6)


ans = 0.26667

sqrt(4+6^3) % or...


ans = 14.832

(4+6^3)^(1/2)


ans = 14.832
3

, 9*6/12 + 7*5^(3+2)


ans = 21880

1 + 5*3/6^2 + 2^(2-4) *1/5.5


ans = 1.4621



Problem 2.4

(a) The area of a circle is Define r as 5, then find the area of a circle, using MATLAB®.

r=5


r = 5


area=pi*r^2


area = 78.54


(b) The surface area of a sphere is . Find the surface area of a sphere with a radius of 10 ft.

r=10


r = 10

surface_area=4*pi*r^2


surface_area = 1256.6


(c) The volume of a sphere is 4/3pr2. Find the volume of a sphere with a radius of 2 ft.


r=2


r = 2

volume=4/3*pi*r^3


volume = 33.51



Problem 2.5
(a) The area of a square is the edge length squared (A = edge2). Define the edge length as 5, then find
the area of a square, using MATLAB®.

edge=5


edge = 5
4

Document information

Uploaded on
December 30, 2025
Number of pages
258
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$22.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
PrepMart
4.8
(215)
Sold
138
Followers
1
Items
2185
Last sold
1 day ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions