Geoscience Reference
In-Depth Information
which yields
H =
2 3
9 3
4 -1
Another important way to manipulate arrays is to sort their elements. As an
example we can use sort(C,dim,mode) with dim=1 and mode='ascend' to sort
the elements of C in ascending order along the i rst array dimension (i.e., the
rows). Typing
I = sort(C,1,'ascend')
yields
I =
1 3 -1
2 4 3
6 6 3
9 9 3
h e function sortrows(C,column) with column=2 sorts the rows of C according
to the second column. Typing
J = sortrows(C,2)
yields
J =
9 3 -1
2 4 3
6 6 3
1 9 3
Array manipulation also includes the comparison of arrays, for example
by checking whether elements in A(i,j) are also found in B using ismember .
Typing
A, B
K = ismember(A,B)
yields
A =
2 4 3
9 3 -1
B =
1 9 3
6 6 3
Search WWH ::




Custom Search