Exercises
Answer each question.
-
Solve these problems in Matlab
A=[3 0 1;-2 4 6; -3 1 5]
B=[1 -1 4; .5 0 3.2; 1.4 -1.1 3]
C=A*B -
Solve these problems in Matlab
A=[1 2 3 4;-4 -3 -2 -1;1 0 1 0 ; 4.1 2 4.1 2];
B=[1 0 0 -3;4 2 1.1 -.3;3 -9 3 2;1 2.1 3 4];
C=A*B -
How you get the first, fourth, and 17th rows of a matrix named P?
To get only the first, fourth, and 17th columns from a matrix named P, use this term:
P([1,4,17],:)
, which can be read all columns of rows 1,4, and 17 of P. -
Use Matlab to create a subset of a matrix named
S
that includes only the values that are in odd rows and even columns of matrix namedS
?[r,c] = size(S);
T = S([1:2:r],[2:2:c]Note: The syntax is
matrixName( vectorOfRowNumbers, vectorOfColNumbers )
. -
Assuming that you correctly entered the matrix
SCRIBNER_DECIMAL_C
as described in Example 6, what command would return the value for a log that was 21 inches in width and 10 feet long?Can you think of a way to get the correct result using variable named
W
that contains the width in inches and a variable namedL
that contains the length in feet?SCRIBNER_DECIMAL_C(16,4)
The following command would work if the width in W is an integer from 6 to 30 and the length in L is an even integer from 6 to 16:
SCRIBNER_DECIMAL_C(W-5,L/2+1)
We will learn how to test for valid values in the programming unit of the course.