The following examples will illustrate how to find, change, add or delete data in a vector. The same principles apply to manipulation of data in matrix form. (a) Finding Data: Suppose we wish to find the elements of vector V which are greater than or equal to 7: V = [-2 3 7 -26 48 10 -8]', i = find(V>=7) results in V = -2 3 7 -26 48 10 -8 i = 3 5 6 The statement, i = find(V>=7), returns a vector, i, containing the index of the elements of V which are greater than or equal to 7. The third, fifth and sixth elements of V are ≥ 7. There are six relational operators that can be used in Matlab: Relational Operators < less than <= less than or equal to > greater than >= greater than or equal to == equal to ~= not equal to (b) Deleting Data: Specific elements in a matrix or vector can be deleted using the empty matrix (or vector), []. The statement x = [] assigns a matrix of dimension zero-by-zero to x. To delete the elements of V which are greater than or equal to seven, use the command V(i) = [] which returns V = -2 3 -26 -8 The elements of V which have indices given by the elements of i, are removed by assigning them to an empty matrix. Single elements may be removed in similar fashion. The command V(3) = [] deletes the third element of V and returns V = -2 3 -8 An efficient way of removing rows and columns of a matrix is to assign them to an empty matrix. The command, A(:,3)=[], deletes column 3 of matrix A. (c) Adding Data: Suppose we wish to combine the elements of vectors V and U: U = [3:2:10]', W = [V; U] This returns U = 3 5 7 9 W = -2 3 -8 3 5 7 9 If we wish to add a single data point (-17) to the end of vector W: W = [W; -17] This returns W = -2 3 -8 3 5 7 9 -17 (d) Replacing Data: To replace the fourth element of W with -12, enter the following W(4) = -12 This returns W = -2 3 -8 -12 5 7 9 -17