• 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 293 pages
Exam (elaborations)

MATLAB: A Practical Introduction to Programming and Problem Solving Second Edition SOLUTION MANUAL

Document preview thumbnail
Preview 4 out of 293 pages

MATLAB: A Practical Introduction to Programming and Problem Solving Second Edition SOLUTION MANUAL

Content preview

MATLAB: A Practical Introduction to
Programming and Problem Solving

Second Edition

SOLUTION MANUAL




Stormy Attaway

College of Engineering
Boston University

,I. Introduction to Programming Using MATLAB

Chapter 1: Introduction to MATLAB

Exercises

1) Create a variable to store the atomic weight of silicon (28.085).

>> siliconAtWt = 28.085
siliconAtWt =
28.0850

2) Create a variable myage and store your age in it. Subtract one from the value of
the variable. Add two to the value of the variable.

>> myage = 35;
>> myage = myage - 1;
>> myage = myage + 2;

3) Use the built-in function namelengthmax to find out the maximum number of
characters that you can have in an identifier name under your version of MATLAB.

>> namelengthmax
ans =
63

4) Explore the format command in more detail. Use help format to find options.
Experiment with format bank to display dollar values.

>> format +
>> 12.34
ans =
+
>> -123
ans =
-
>> format bank
>> 33.4
ans =
33.40
>> 52.435
ans =

, 52.44

5) Find a format option that would result in the following output format:
>> 5/16 + 2/7
ans =
67/112

>> format rat
>> 5/16 + 2/7
ans =
67/112

6) Think about what the results would be for the following expressions, and then
type them in to verify your answers.
* 4
3 + 4 ^ 2
4 \ 12 + 4
3 ^ 2
(5 – 2) * 3

>> * 4
ans =
25

>> 3 + 4 ^ 2
ans =
19

>> 4 \ 12 + 4
ans =
7

>> 3 ^ 2
ans =
9

>> (5 - 2) * 3
ans =
9

7) The combined resistance RT of three resistors R1, R2, and R3 in parallel is given
by
1
RT = 1 1 1
 
R1 R2 R3

, Create variables for the three resistors and store values in each, and then
calculate the combined resistance.

>> r1 = 3;
>> r2 = 2.2;
>> r3 = 1.5;
>> rt = 1/(1/r1 + 1/r2 + 1/r3)
rt =
0.6875

As the world becomes more “flat”, it is increasingly important for engineers and
scientists to be able to work with colleagues in other parts of the world. Correct
conversion of data from one system of units to another (for example, from the
metric system to the American system or vice versa) is critically important.

8) Create a variable pounds to store a weight in pounds. Convert this to kilograms
and assign the result to a variable kilos. The conversion factor is 1 kilogram = 2.2
pounds.

>> pounds = 30;
>> kilos = pounds / 2.2
kilos =
13.6364

9) Create a variable ftemp to store a temperature in degrees Fahrenheit (F). Convert
this to degrees Celsius (C) and store the result in a variable ctemp. The conversion
factor is C = (F – 32) * 5/9.

>> ftemp = 75;
>> ctemp = (ftemp - 32) * 5/9
ctemp =
23.8889

10) Find another quantity to convert from one system of units to another.

>> kmPerMile = 1.6093;
>> miles = 6;
>> km = miles * kmPerMile
km =
9.6558

11) The function sin calculates and returns the sine of an angle in radians. Use help
elfun to find the name of the function that returns the sine of an angle in degrees.
Verify that calling this function and passing 90 degrees to it results in 1.

>> sind(90)

Connected book
 image
Stormy Attaway Matlab
Publisher: 2013 ISBN: 9780124058934 Edition: Unknown

Document information

Uploaded on
September 3, 2024
Number of pages
293
Written in
2024/2025
Type
Exam (elaborations)
Contains
Only questions
$25.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.
PremiumExamBank
4.8
(1071)
Sold
520
Followers
78
Items
10579
Last sold
13 hours 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