A few words of thanks would be greatly appreciated.
Concatenate vectors or matrices under Matlab
The operation to concatenate vectors or matrices under MATLAB is defined as a combination of the variables in a single vector or matrix. There are two types of concatenation operation - horizontal and vertical concatenation. For horizontal concatenation,two variables should have the same number of rows. In case of vertical concatenation,two variables should have the same number of columns. Every available variable cannot be concatenated. Concatenation operations with multiple variables in MATLAB software are possible as well, as one vector can be concatenated with the transpose of the same vector. It is possible to concatenate vectors or matrices under MATLAB in a logical way.
Horizontal concatenation can be done using vectors, matrices or simple variables. The two variables (X and Y) must have the same number of rows. The code is as follows:
Result = [X Y]
Vertical concatenation
Vertical concatenation can be done using vectors, matrices or simple variables. The two variables (X and Y) must have the same number of columns. The code is as follows:
Result = [X, Y]
Further calculations
Option 1
You can concatenate a row with a column, transposing a row as a column or vice versa. For example:
X = | 1 2 |
| 2 |
Y = | 3 |
| 5 |
Using the command:
Result = [X Y]
Result = | 1 2 2 3 5 |
Using the command:
Result = [X ', Y]
| 1 |
| 2 |
Result = | 2 |
| 3 |
| 5 |
Option 2
You can extend this principle to cover multiple variables. For example. Using the following set of variable: