# How to MERGE NON-IDENTICAL SIZE matrix in MATLAB

In previous post, we discussed about How to merge identical size matrix in MATLAB. Now in

**Post-12 of Module-01**, we will discuss about how to merge non-identical size matrix in matlab.
To understand this problem, we are taking four different size matrix of

**3x2, 2x3, 1x3**and**2x5**resolution in variable**E, F, G**and**H**respectively. These matrices has been loaded in MATLAB using command written in**line 6 to 9**of matlab program shown in**figure-1**. The command written in line 6 to 9 has been used without any**semicolon (;)**after command completion. Because of this removal of semicolon, all four matrix will be display on command window i.e. no need to retype four matrix variable name in editor window again, as used in previous post.
Figure.1 - MATLAB Program for Merge of Non-Identical Matrix.

As the size of four matrix are not same, hence we cannot merge all four matrix directly. Therefore, we will add these matrix one by one. we will select two matrix which either have common row or column.

First of all adding, matrix F and G row-wise, as it has common number of column i.e. 3. After adding 2 rows of F and 1 row of G, merged matrix FG will generated with size of 3x3.

Now we have

**E(3x2), FG(3x3) and H(2x5)**. Matrix E and FG has common number of rows i.e. 2. Therefore, we will add 2 columns of E and 3 columns of FG, due to which a matrix EFG will be generated with size of 3x5.
Now we have

**EFG(3x5) and H(2x5)**. This two matrix has 5 common columns. Therefore, we will add 3 rows of EFG and 2 rows of H, which will generate a matrix**EFGH**with the size of**5x5**.
To run this matlab program, click on

**'Run mod0112.m'**button, which will generate output of matlab program on command window. Given four matrices has been shown in figure-2.
Figure.2 - Command Window output for Merge of Non-Identical Matrix with given matrix.

Figure.3 - Command Window Output for Merge of Non-Identical Matrix with merged matrix.

The matrix EFGH is a merged matrix obtained using above matlab matlab program. Now next question which comes into our mind is that, how to break matrix into number of sub-matrix in MATLAB. This problem we will discuss in our next post.

**Video Tutorial :**How To Merge Multiple Matrix in MATLAB By INFO4EEE

Brought to you By INFO4EEE : Website, Channel, and Classes.

[…] we discussed about, How to merge non-identical size matrix in MATLAB. Now in Post-13 of Module-01, We will discuss how to split matrix into number of sub-matrix in […]

ReplyDelete[…] How to merge non-identical size matrix in MATLAB. In this matlab tutorial, we took four different size matrix of 3×2, 2×3, 1×3 and 2×5 and merge them to form single matrix. […]

ReplyDelete[…] Read Post-12 of Module-I: How To Merge NON-IDENTICAL SIZE Matrix in MATLAB […]

ReplyDelete[…] How to MERGE NON-IDENTICAL SIZE matrix in MATLAB […]

ReplyDelete