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


matrix

Muda a forma de vetores ou matrizes

Seqüência de Chamamento

y = matrix(v, m, n)
y = matrix(v, m1, m2, m3, ..)
y = matrix(v, [sizes])

Parâmetros

v

vetor, matriz ou hipermatriz

n, m, m1, m2, ..

inteiros

sizes

vetor de inteiros

y

vetor, matriz ou hipermatriz

  • y = v(:) is equivalent to matrix(v,-1, 1)
  • matrix() can be overloaded for any mlist() type, with a function named %<type>_matrix(v,s,..) with at least 2 input arguments.

Descrição

Para um vetor ou matriz com n x m entradas, o comando y=matrix(v,n,m) ou, de modo similar, y=matrix(v,[n,m]) transforma o vetor (ou matriz) v em uma matriz nxm empilhando as entradas coluna a coluna de v.

Se uma das dimensões m ou n é igual a -1, ela é automaticamente atribuída ao quociente de tamanho (v,'*') pela outra dimensão,

Para uma hipermatriz tal como prod(size(v))==prod(sizes), o comando y=matrix(v,sizes) (ou equivalentemente y=matrix(v,n1,n2,...nm)) transforma v em uma matriz ou hipermatriz empilhando "coluna a coluna" as entradas de v (a primeira dimensão variando primeiro). y=matrix(v,sizes) resulta numa matriz regular se os tamanhos são escalares ou um vetor de duas entradas.

  • y = v(:) is equivalent to matrix(v,-1, 1)
  • matrix() can be overloaded for any mlist() type, with a function named %<type>_matrix(v,s,..) with at least 2 input arguments.

Exemplos

With a regular matrix of decimal numbers:

a = [1 3 5 7 9 11; 2 4 6 8 10 12]
matrix(a, 4, 3)
matrix(a, [3 4])
matrix(a, 3, -1)
// into an hypermatrix:
matrix(a, 3, 2, 2)

With texts:

t = strsplit("a":"x",1:23)'
matrix(t,[3,8])
--> t = strsplit("a":"x",1:23)'
 t  =
!a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  !

--> matrix(t,[3,8])
 ans  =
!a  d  g  j  m  p  s  v  !
!b  e  h  k  n  q  t  w  !
!c  f  i  l  o  r  u  x  !

With a cells hyperarray:

c = makecell([2,3,2], %t,%z, %i,"abc", list(%pi,"a"), int8(23),cos,sind,"àèìòù",corelib, 0.5, 1/%z^2)
rc = matrix(c, 3, 4)
rc(8)==c(8)
rc{8}.getshell
 c  =
(:,:,1)
  [1x1 boolean]  [1x1 polynomial]  [1x1 constant]
  [1x1 string ]  [    list      ]  [1x1 int8    ]
(:,:,2)
  [      1 fptr   ]  [      1 function]  [1x1 string]
  [        library]  [    1x1 constant]  [    r     ]

--> rc = matrix(c, 3, 4)
 rc  =
  [1x1 boolean   ]  [    list    ]  [      1 fptr    ]  [1x1 constant]
  [1x1 string    ]  [1x1 constant]  [        library ]  [1x1 string  ]
  [1x1 polynomial]  [1x1 int8    ]  [      1 function]  [    r       ]

--> rc(8)==c(8)
 ans  =
  T

--> rc{8}.getshell
 ans  =
 cmd

With a structures array:

clear s
s(3,6).r = %pi
matrix(s,2,9)
--> s(3,6).r = %pi
 s  =
  3x6 struct array with fields:
    r

--> matrix(s,2,9)
 ans  =
  2x9 struct array with fields:
    r
Report an issue
<< flipdim Matrix manipulation permute >>

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