Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.0.0 - Português


cat

concatena vários arrays

Seqüência de Chamamento

y = cat(dim, A1, A2,..., An)

Parâmetros

dim

um escalar real positivo

A1,A2,..An

escalares, vetores, matrizes, multi-arrays ou cell arrays. A1, A2, ..., An, devem ter o mesmo tamanho (excluindo o número de dimensão dim). size(A1,i)=size(A2,i)=...=size(An,i) para i diferente de dim e size(A1,dim), size(A2,dim),...,size(An,dim) podem ser diferentes

y

um escalar, vetor, matriz ou multi-array, y tem o mesmo tipo de A1,A2,...,An

Descrição

y=cat(dim,A1,A2,...,An) : y é o resutado da concatenação dos argumentos de entrada A1, A2, ..., An. Se dim= 1, então a concatenação é feita de acordo com as linhas; se dim= 2, então a concatenação é feita de acordo com as colunas dos argumentos de entrada.

cat(1, A1, A2, A3) is equivalent to [A1 ; A2 ; A3]. cat(2, A1, A2, A3) is equivalent to [A1 A2 A3]. Brackets are faster and must be preferred in both cases.

cat() is useful mainly for dim > 2, to build an hypermatrix or hypercell.

Exemplos

Example #1: Building a vector along dim #3

cat(3, 4, -1, 3)
--> cat(3, 4, -1, 3)
 ans  =
(:,:,1)
   4.
(:,:,2)
  -1.
(:,:,3)
   3.

Example #2: Building a matrix of text of size(1,3,2):

cat(3, ["a" "aa" "aaa"], ["b" "bb" "bbb"])
--> cat(3, ["a" "aa" "aaa"], ["b" "bb" "bbb"])
 ans  =
(:,:,1)
!a  aa  aaa  !
(:,:,2)
!b  bb  bbb  !

Example #3: Stacking separate R G B layers of a mini RGB image:

R = uint8(grand(2,4,"uin",0,255))
G = uint8(grand(2,4,"uin",0,255))
B = uint8(grand(2,4,"uin",0,255))
cat(3, R, G, B)
--> R = uint8(grand(2,4,"uin",0,255))
 R  =
  142    8   11  234
  191  249  252   51

--> G = uint8(grand(2,4,"uin",0,255))
 G  =
  255  246  104  89
  152   71  112  17

--> B = uint8(grand(2,4,"uin",0,255))
 B  =
  170  182  39  197
  115  108  16   51

--> cat(3, R, G, B)
 ans  =
(:,:,1)
  142    8   11  234
  191  249  252   51
(:,:,2)
  255  246  104  89
  152   71  112  17
(:,:,3)
  170  182  39  197
  115  108  16   51

Example #4: Building an hypercell:

A1 = {%T   "abc" ; (1-%z)^2,  %pi}
A2 = {%s^2, gda(); %F, list(-5, "hello")}
cat(3, A1, A2)
--> A1 = {%T   "abc" ; (1-%z)^2,  %pi}
 A1  =
  [1x1 boolean   ]  [1x1 string  ]
  [1x1 polynomial]  [1x1 constant]

--> A2 = {%s^2, gda(); %F, list(-5, "hello")}
 A2  =
  [1x1 polynomial]  [1x1 handle]
  [1x1 boolean   ]  [    list  ]

--> cat(3, A1, A2)
 ans  =
(:,:,1)
  [1x1 boolean   ]  [1x1 string  ]
  [1x1 polynomial]  [1x1 constant]

(:,:,2)
  [1x1 polynomial]  [1x1 handle]
  [1x1 boolean   ]  [    list  ]

Ver Também

  • brackets [..] — Concatenation. Recipients of an assignment. Results of a function
  • lstcat — concatenação de listas
  • permute — permutes the dimensions of an array
  • matrix — Muda a forma de vetores ou matrizes
Report an issue
<< Shape tests Matrix manipulation circshift >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Mar 27 09:49:52 GMT 2023