Geoscience Reference
In-Depth Information
for array manipulation, which are used later in the topic. We i rst clear the
workspace and create two arrays, A and B , by typing
clear
A = [2 4 3; 9 3 -1]
B = [1 9 3; 6 6 3]
which yields
A =
2 4 3
9 3 -1
B =
1 9 3
6 6 3
When we work with arrays, we sometimes need to concatenate two or more
arrays into a single array. We can use either cat(dim,A,B) with dim=1 to
concatenate the arrays A and B along the i rst dimension (i.e., along the rows).
Alternatively, we can use the function vertcat to concatenate the arrays A and
B vertically. By typing either
C = cat(1,A,B)
or
C = vertcat(A,B)
we obtain (in both cases)
C =
2 4 3
9 3 -1
1 9 3
6 6 3
Similarly, we can concatenate arrays horizontally, i.e., concatenate the arrays
along the second dimension (i.e., along the columns) by typing
D = cat(2,A,B)
or using the function horzcat instead
D = horzcat(A,B)
which both yield
D =
Search WWH ::




Custom Search