Você está na página 1de 3

29/10/2017 Concatenar cordas horizontalmente - MATLAB strcat

strcat
Concatenar strings horizontalmente

Sintaxe

s = strcat(s1,...,sN)

Descrio
s = strcat(s1,...,sN)concatena horizontalmente s1,...,sN. Cada argumento de entrada pode ser exemplo
uma matriz de caracteres, uma matriz de clulas de vetores de caracteres ou uma matriz de caracteres.
Se alguma entrada uma matriz de string, o resultado uma matriz de string.
Se qualquer entrada uma matriz de clulas e nenhuma delas arrays de cordas, o resultado
uma matriz de clulas de vetores de caracteres.
Se todas as entradas so arrays de caracteres, o resultado uma matriz de caracteres.

Para as entradas de matriz de caracteres, strcatremove os caracteres de espao em branco ASCII de


arrastar: espao, guia, guia vertical, linha nova, retorno de carro e alimentao de formulrio. Para
entradas de matriz de clulas e cadeias, strcatno remove o espao em branco que est direita.

Exemplos recolher todos

Concatenar dois vetores de caracteres

Try it in MATLAB

s1 = 'Bom' ;
s2 = 'manh' ;
s = strcat (s1, s2)

s =
'Bom Dia'

Concatenar duas matrizes de clulas

Try it in MATLAB

s1 = { 'abcde' , 'fghi' };
s2 = { 'jkl' , 'mn' };
s = strcat (s1, s2)

s = matriz de clulas 1x2


{'abcdejkl'} {'fghimn'}

https://www.mathworks.com/help/matlab/ref/strcat.html 1/3
29/10/2017 Concatenar cordas horizontalmente - MATLAB strcat

Concatenar duas matrizes de clulas com matriz de clulas escalares

Try it in MATLAB

firstnames = { 'Abraham' ; 'George' };


lastnames = { 'Lincoln' ; 'Washington' };
names = strcat (lastname, { ',' }, firstnames)

nomes = matriz de clulas 2x1


{'Lincoln, Abraham'}
{'Washington, George'}

Concatenar Arrays de duas cadeias de caracteres

Comeando no R2017a, voc pode criar matrizes de cordas usando


aspas duplas em vez da stringfuno. Concatene-os com a Try it in MATLAB
strcatfuno.

str1 = [ "John" , "Mary" ];


str2 = [ "Smith" , "Jones" ];
str = strcat (str1, str2)

str = 1x2 string array


"John Smith" "Mary Jones"

Concatenate a character vector onto each element of the string array.

str = strcat(str,', M.D.')

str = 1x2 string array


"John Smith, M.D." "Mary Jones, M.D."

Text processing functions (such as strfind and regexp) accept string arrays as inputs, but other functions (for
example, addpath) do not.

Input Arguments collapse all

s1,...,sN Input text


character arrays | cell array of character vectors | string arrays

Input text, specified as character arrays, cell arrays of character vectors, or string arrays. When combining string
or cell arrays with character arrays, the string or cell arrays must be either scalars or column vectors with the
same number of rows as the character arrays.

Data Types: char | cell | string

Tips
Character arrays also can be concatenated using left and right square brackets.

s1 = 'Good ';

https://www.mathworks.com/help/matlab/ref/strcat.html 2/3
29/10/2017 Concatenar cordas horizontalmente - MATLAB strcat

s2 = 'Morning';
s = [s1 s2]

s =

Good Morning

See Also
cat | cellstr | horzcat | join | strjoin | vertcat

Introduced before R2006a

How useful was this information?


5
4
3
2
1
Not Useful
Very Useful

https://www.mathworks.com/help/matlab/ref/strcat.html 3/3

Você também pode gostar