Enjoy immediate access to the full Solution Manual for MATLAB: A Practical Introduction to Programming and Problem Solving 5th Edition in PDF.
Enjoy immediate access to the full Solution Manual for MATLAB: A Practical Introduction to Programming and Problem Solving 5th Edition in PDF.
https://testbankmall.com/product/solution-manual-for-organizational-
behavior-a-practical-problem-solving-approach-3rd-edition-angelo-
kinicki/
https://testbankmall.com/product/solution-manual-for-problem-solving-
and-programming-concepts-9-e-9th-edition-maureen-sprankle-jim-hubbard/
https://testbankmall.com/product/test-bank-for-organizational-
behavior-a-practical-problem-solving-approach-3rd-edition-angelo-
kinicki/
https://testbankmall.com/product/test-bank-for-organizational-
behavior-a-practical-problem-solving-approach-2nd-edition-by-kinicki/
Test Bank for Organizational Behavior: A Practical,
Problem-Solving Approach, 3rd Edition Angelo Kinicki
https://testbankmall.com/product/test-bank-for-organizational-
behavior-a-practical-problem-solving-approach-3rd-edition-angelo-
kinicki-3/
https://testbankmall.com/product/test-bank-for-problem-solving-and-
programming-concepts-9-e-9th-edition-0132492644/
https://testbankmall.com/product/solution-manual-for-c-programming-
from-problem-analysis-to-program-design-5th-edition-barbara-doyle/
https://testbankmall.com/product/solution-manual-for-business-
communication-a-problem-solving-approach-1st-by-rentz/
https://testbankmall.com/product/solution-manual-for-data-structures-
and-problem-solving-using-c-2-e-mark-a-weiss/
3 4 5 6 7 8
9 7 5 3
>> 3:8
ans =
3 4 5 6 7 8
>> 1.3: 0.4: 2.5
ans =
1.3000 1.7000 2.1000 2.5000
>> 9: -2: 3
ans =
9 7 5 3
6) Using a built-in function, create a vector vec which consists of 30 equally spaced
points in the range from –2*pi to +pi.
7) Write an expression using linspace that will result in the same as 1:0.5:3
>> 1: 0.5: 3
ans =
1.0000 1.5000 2.0000 2.5000 3.0000
>> linspace(1,3,5)
ans =
1.0000 1.5000 2.0000 2.5000 3.0000
8) Using the colon operator and also the linspace function, create the following row
vectors:
-4 -3 -2 -1 0
9 7 5
4 6 8
>> -4:0
ans =
-4 -3 -2 -1 0
>> linspace(-4, 0, 5)
ans =
-4 -3 -2 -1 0
>> 9:-2:5
ans =
9 7 5
>> linspace(9, 5, 3)
ans =
9 7 5
>> 4:2:8
ans =
4 6 8
>> linspace(4,8,3)
ans =
4 6 8
9) How many elements would be in the vectors created by the following expressions?
linspace(3,2000)
logspace(3,2000)
10) Create a variable myend which stores a random integer in the inclusive range from
5 to 9. Using the colon operator, create a vector that iterates from 1 to myend in steps
of 3.
11) Create two row vector variables. Concatenate them together to create a new row
vector variable.
12) Using the colon operator and the transpose operator, create a column vector
myvec that has the values -1 to 1 in steps of 0.5.
colvec = 1:3’
14) Write an expression that refers to only the elements that have odd-numbered
subscripts in a vector, regardless of the length of the vector. Test your expression on
vectors that have both an odd and even number of elements.
15) Generate a 2 x 4 matrix variable mat. Replace the first row with 1:4. Replace the
third column (you decide with which values).
16) Generate a 2 x 4 matrix variable mat. Verify that the number of elements is equal to
the product of the number of rows and columns.
17) Which would you normally use for a matrix: length or size? Why?
18) When would you use length vs. size for a vector?
>> rand(2,3)
ans =
0.5208 0.5251 0.1665
0.1182 0.1673 0.2944
>> rand(2,3)*5
ans =
1.9468 2.3153 4.6954
0.8526 2.9769 3.2779
20) Create a variable rows that is a random integer in the inclusive range from 1 to 5.
Create a variable cols that is a random integer in the inclusive range from 1 to 5.
Create a matrix of all zeros with the dimensions given by the values of rows and cols.
21) Create a vector variable vec. Find as many expressions as you can that would
refer to the last element in the vector, without assuming that you know how many
elements it has (i.e., make your expressions general).
22) Create a matrix variable mat. Find as many expressions as you can that would
refer to the last element in the matrix, without assuming that you know how many
elements or rows or columns it has (i.e., make your expressions general).
The function flip is equivalent to the function fliplr for a row vector.
The function flip is equivalent to the function flipud for a column vector.
The function flip is equivalent to the function flipud for a matrix.
26) Use reshape to reshape the row vector 1:4 into a 2x2 matrix; store this in a variable
named mat. Next, make 2x3 copies of mat using both repelem and repmat.
27) Create a 3 x 5 matrix of random real numbers. Delete the third row.
>> mat(3,:) = []
mat =
0.5226 0.9797 0.8757 0.0118 0.2987
0.8801 0.2714 0.7373 0.8939 0.6614
Because the left and right sides are not the same dimensions.
30) Create a vector x which consists of 20 equally spaced points in the range from – to
+. Create a y vector which is sin(x).
>> x = linspace(-pi,pi,20);
>> y = sin(x);
31) Create a 3 x 5 matrix of random integers, each in the inclusive range from -5 to 5.
Get the sign of every element.
32) Find the sum 2+4+6+8+10 using sum and the colon operator.
>> sum(2:2:10)
ans =
30
33) Find the sum of the first n terms of the harmonic series where n is an integer
variable greater than one.
1 1 1 1
1 + + + + +…
2 3 4 5
>> n = 4;
>> sum(1./(1:n))
ans =
2.0833
34) Find the following sum by first creating vectors for the numerators and
denominators:
3 5 7 9
+ + +
1 2 3 4
35) Create a matrix and find the product of each row and column using prod.
>> prod(mat)
ans =
55 240 80
>> prod(mat,2)
ans =
4224
250
36) Create a 1 x 6 vector of random integers, each in the inclusive range from 1 to 20.
Use built-in functions to find the minimum and maximum values in the vector. Also
create a vector of cumulative sums using cumsum.
37) Write a relational expression for a vector variable that will verify that the last value in
a vector created by cumsum is the same as the result returned by sum.
38) Create a vector of five random integers, each in the inclusive range from -10 to 10.
Perform each of the following:
40) Find two ways to create a 3 x 5 matrix of all 100s (Hint: use ones and zeros).
ones(3,5)*100
zeros(3,5)+100
A B
é 1 2 3 ùé
ê 2 4 1 ù
ú ê ú
ë 4 -1 6 û ë 1 3 0 û
é2 8 3 ù
ê ú
ë 4 -3 0 û
42) A vector v stores for several employees of the Green Fuel Cells Corporation their
hours worked one week followed for each by the hourly pay rate. For example, if the
variable stores
>> v
v =
33.0000 10.5000 40.0000 18.0000 20.0000 7.5000
that means the first employee worked 33 hours at $10.50 per hour, the second worked
40 hours at $18 an hour, and so on. Write code that will separate this into two vectors,
one that stores the hours worked and another that stores the hourly rates. Then, use
the array multiplication operator to create a vector, storing in the new vector the total
pay for every employee.
>> mat
mat =
1 -5 0 -2 10
2 1 1 6 -3
-6 10 -3 5 2
>> sum(sum(mat < 0))
ans =
5
44) A company is calibrating some measuring instrumentation and has measured the
radius and height of one cylinder 8 separate times; they are in vector variables r and h.
Find the volume from each trial, which is given by Πr2h. Also use logical indexing first to
make sure that all measurements were valid (> 0).
3 12
9 6
• Are there any other matrix multiplications that can be performed? If so, list them.
C*B
46) Create a row vector variable r that has 4 elements, and a column vector variable c
that has 4 elements. Perform r*c and c*r.
47) The matrix variable rainmat stores the total rainfall in inches for some districts for
the years 2014-2017. Each row has the rainfall amounts for a given district. For
example, if rainmat has the value:
>> rainmat
ans =
25 33 29 42
53 44 40 56
etc.
district 1 had 25 inches in 2014, 33 in 2015, etc. Write expression(s) that will find the
number of the district that had the highest total rainfall for the entire four year period.
48) Generate a vector of 20 random integers, each in the range from 50 to 100. Create
a variable evens that stores all of the even numbers from the vector, and a variable
odds that stores the odd numbers.
49) Assume that the function diff does not exist. Write your own expression(s) to
accomplish the same thing for a vector.
50) Create a vector variable vec; it can have any length. Then, write assignment
statements that would store the first half of the vector in one variable and the second
half in another. Make sure that your assignment statements are general, and work
whether vec has an even or odd number of elements (Hint: use a rounding function
such as fix).