
- Matlab Tutorial
- MATLAB - Home
- MATLAB - Overview
- MATLAB - Environment Setup
- MATLAB - Syntax
- MATLAB - Variables
- MATLAB - Commands
- MATLAB - M-Files
- MATLAB - Data Types
- MATLAB - Operators
- MATLAB - Decisions
- MATLAB - Loops
- MATLAB - Vectors
- MATLAB - Matrix
- MATLAB - Arrays
- MATLAB - Colon Notation
- MATLAB - Numbers
- MATLAB - Strings
- MATLAB - Functions
- MATLAB - Data Import
- MATLAB - Data Output
- MATLAB Advanced
- MATLAB - Plotting
- MATLAB - Graphics
- MATLAB - Algebra
- MATLAB - Calculus
- MATLAB - Differential
- MATLAB - Integration
- MATLAB - Polynomials
- MATLAB - Transforms
- MATLAB - GNU Octave
- MATLAB - Simulink
- MATLAB Useful Resources
- MATLAB - Quick Guide
- MATLAB - Useful Resources
- MATLAB - Discussion
MATLAB - Concatenating Matrices
You can concatenate two matrices to create a larger matrix. The pair of square brackets '[]' is the concatenation operator.
MATLAB allows two types of concatenations −
- Horizontal concatenation
- Vertical concatenation
When you concatenate two matrices by separating those using commas, they are just appended horizontally. It is called horizontal concatenation.
Alternatively, if you concatenate two matrices by separating those using semicolons, they are appended vertically. It is called vertical concatenation.
Example
Create a script file with the following code −
a = [ 10 12 23 ; 14 8 6; 27 8 9] b = [ 12 31 45 ; 8 0 -9; 45 2 11] c = [a, b] d = [a; b]
When you run the file, it displays the following result −
a = 10 12 23 14 8 6 27 8 9 b = 12 31 45 8 0 -9 45 2 11 c = 10 12 23 12 31 45 14 8 6 8 0 -9 27 8 9 45 2 11 d = 10 12 23 14 8 6 27 8 9 12 31 45 8 0 -9 45 2 11
matlab_matrics.htm
Advertisements