Concatenate vectors or matrices under Matlab

Last update on May 28, 2009 02:41 PM by jak58
Published by jak58

Concatenate vectors or matrices under Matlab





Concatenation of variables Matlab is define as the combination these variables in a single (vector or matrix).

Example:

       	  | 2 3 4 | 
X = 	| 1 2 5 | 
       	  | 0 2 7 | 


With:
       	  | 9 6 8 | 
Y = 	| 5 6 2 | 
      	  | 3 2 1 | 


(concatenation of rows):
                   | 9 6 8 2 3 4 | 
Result =	| 1 2 5 5 6 2 | 
              	   | 0 2 7 3 2 1 | 
 


Or (concatenation of columns):

          	  | 2 3 4 | 
          	  | 1 2 5 | 
          	  | 0 2 7 | 
Result =       | 9 6 8 | 
       	          | 5 6 2 | 
       	          | 3 2 1 | 


From here you may have noticed that not all variables can be concatenate.

Horizontal concatenation


Using X and Y (they can be vectors, matrices or simple variable). It is necessary that the two variables to concatenate have the same number of rows. The code is as follows:

Result = [X Y]

Vertical concatenation


Using X and Y (they can be vectors, matrices or simple variable). It is necessary that the two variables to concatenate have the same number of columns. The code is as follows:

Result = [X, Y]

Further calculations

  • Option 1



You can concatenate a vector (matrix) with the transposed of the other. 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



The principle remains the same, we can concatenate multiple variables, provided the scale is respected.

For example. Using the following set of variable:
A = 1 
B = 2 
C = | 3 4 | 
       | 5 6 | 
D = 7 
E = | 8 9 | 

The command:
Result = [[A;B] C;D E]



             | 1 3 4 | 
Result =  | 2 5 6 | 
             | 7 8 9 |
Best answers for « Concatenate vectors or matrices under Matlab » in :
Vector and bitmap images Show vector images and bitmap images There are two main categories of images: bitmap images (also called raster images): these are pixeled images, i.e. a set of points (pixels) contained in a table, each of these points having one or more values...
String concatenation Show String concatenation String concatenation is the process of joining two character chains or strings end to end into one. Under programming languages, for example , PHP, concatenation is done with “..” and for javascript, it is...
Disabling True Vector Service under Windows XP Show Disabling True Vector Service under Windows XP To shut down True Vector Service, Go to Menu “Start”> “Control Panel” and double-click on “Security Center”. In the below image, select “Windows Firewall” and choose...
PHP Concatenation ShowPHP Concatenation PHP allows you to concatenate strings with the "." $concatenation= $a . $b; Or to affect, in the variable $ a, the value of the concatenation of $ a and $ b: $a.=$b; To concatenate strings and...
Free alternatives to Matlab ShowFree alternatives to Matlab Matlab is a programming and development language for advanced researchers, scientists and students under physics and mathematics fields. It can perform very complex tasks requiring high computing...
Free alternative to Microsoft Visio ShowFree alternative to Microsoft Visio Microsoft Visio is a diagramming program that makes use of vector graphics to create diagrams or patterns. It is currently available in two versions: Standard and Professional. The Standard and...
Download SVG Viewer ShowVG viewer is a plugin allowing to bring the support SVG format (vector graphics) in Web browsers. NB: Since numerous current browsers propose SVG support, Adobe has decided to discontinue support for Adobe SVG on January 1st, 2009.
Download Inkscape ShowAn Open Source vector graphics editor, with capabilities similar to Illustrator, CorelDraw, or Xara X, using the W3C standard Scalable Vector Graphics (SVG) file format. Inkscape supports many advanced SVG features (markers, clones, alpha blending,...
URL manipulation attacks ShowIntroduction to URLs The URL (Uniform Resource Locator) of a web application is the vector that makes it possible to indicate the requested resource. It is a string of printable ASCII characters that is divided into five parts: The name of the...
Spreadsheet - Text Operators ShowConcatenation Operator Spreadsheets generally use an oeprator, called a concatenation operator , that allows two text values to be added together. The concatenation operator, written as &, is used as follows: In the above example, the cell...
Vsmon - vsmon.exe Showvsmon - vsmon.exe vsmon.exe (vsmon stands for True Vector Monitor) is a process which corresponds to a component of the firewall ZoneAlarm. It is an application which can safely be terminated. However, it is recommended that you not do so, in order...