Concatenation, MATLAB in Mathematics


The String concatenation means to join the strings altogether. Of course, as strings are merely vectors of the characters, the technique of concatenating vectors also works for the strings. For illustration, to generate one long string from the two strings, it is possible to join them by placing them in square brackets:


>> first = 'Bird';

>> last = 'house';

>> [first last]

ans =



Also the function strcat does this horizontally, that means that it generates one longer string from the inputs.

>> first = 'Bird';

>> last = 'house';

>> strcat(first,last)

ans =



There is a distinction between these two methods of concatenating, though, if there are leading or trailing blanks in the strings. The technique of using the square brackets will concatenate the strings, involving all leading and trailing blanks.


>> str1 = 'xxx   ';

>> str2 = '   yyy';

>> [str1 str2]

ans =

xxx      yyy

>> length(ans)

ans =



Posted Date: 10/20/2012 5:04:33 AM | Location : United States

Related Discussions:- Concatenation, Assignment Help, Ask Question on Concatenation, Get Answer, Expert's Help, Concatenation Discussions

Write discussion on Concatenation
Your posts are moderated
Related Questions
5 p2+8p+15, 3 p2-3p-18, 12 p2-p-30

Standard Deviation The standard deviation is the square root of variance: The built-in function in a MATLAB for the standard deviation is known as std; the standard dev

Complex numbers: A complex number is commonly written in the form z = a + bi here a is known as the real part of the number z, b be the imaginary part of z, and i is √-1

Writing and Reading Spreadsheet Files: The MATLAB functions xlswrite & xlsread will write to and read from the spreadsheet files which have the extension .xls. For illustratio

Write a MATLAB function [d1, u1, l1, c1, r1] = NaiveGaussArrow(d, u, l, c, r) that takes as input the 5 vectors de ned above representing A. This function performs Naive Gauss redu

Types of User-defined Functions: We know how to write a user-defined function, stored in an M-file, which computes and returns one value. This is merely one type of the functi

Built in recursive function in MATLAB: We have seen that the built-in function in MATLAB to compute factorials, termed as the factorial and we know how to implement the iterat

Give the formula for a rational function that has a hole at x=7 & vertical asmptote at x=-3/2

Nested IF-ELSE statements: The if-else statement is used to select between the two statements. In order to select from more than two statements, the if-else statements can als

Common form of the switch statement: The common form of the switch statement is as shown below:   switch switch_expression   case caseexp1    action1   case cas