Exos
Exos
Calculate:
Exercise 2:
1 2 3
1. Enter the following matrix: A = 2 3 1
3 1 2
2. What are the results of the following commands?
>> A(:)
>> A(5)
>> reshape(A(:),size(A))
1
4. Using the matrix A above, create the following matrix C using matrices concatenation.
Exercise 3:
(1) Create the row vector x = [1:10] and the column vector y = x' and the 10x10 matrix z = y*x
- The number of elements in z with values greater than 10 but less than 90.
- The mean of all the values in z which do not lie along an edge of the matrix.
(2) Note that to find the first n elements in a matrix A that meet a given logical condition
L(A) with matlab, we can use the command: find(L(A),n). On the other hand, to find the
last n elements in a matrix A that satisfy the logical condition L(A), we can add a third
argument ’last’, that is we use the command find(L(A),n, ’last’).
- Create a 4-by-4 magic square matrix and find the first five elements that are less than
10. Then View those elements of A.
- Repeat the question for the last five elements.
- According to you, what will be the result of the matlab command:
[row,col]=find(A<10,5)
Exercise 4:
2
2
N − 1 i =1
X
of X.
6. Calculate the differential vector dX = X i+1 − X i for i = 1,2, , N − 1 .