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

Change language to:
English - Français - 日本語 - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Ajuda do Scilab >> Estruturas de Dados > type


tipo de variável

Seqüência de Chamamento




objeto Scilab




type(x)retorna um inteiro que indica o tipo de xcomo segue:

1 : uma matriz constante de reais ou complexos;

2 : uma matriz de polinômios;

4 : uma matriz de valores booleanos;

5 : uma matriz esparsa;

6 : uma matriz de valores booleanos esparsa;

7 : uma matriz esparsa do Matlab.

8 : uma matriz de inteiros armazenados em 1, 2, 4 ou 8 bytes;

9 : uma matriz de manipuladores gráficos;

10 : uma matriz de strings;

13 : uma função compilada (código Scilab);

14 : uma biblioteca de funções;

15 : uma lista;

16 : uma lista com tipo ("typed list" ou "tlist");

17 : uma lista com tipo orientada matricialmente (mlist);

128 : um ponteiro (identificador) para um bloco Xcos, para um resultado de lufact(), etc.

129 : polinômio de tamanho implícito, usado para indexação.

130 : intrínseco do Scilab (código C ou Fortran).

0 : An undefined component of a simple list. Such a component may be met as an omitted input argument when calling Scilab function like in foo(a,,b): From within the function, the missing argument is defined but is of null type. Defining L=list(%pi,,%i,,,%z) creates L(2) of type 0; etc. For these objects, isdef() returns %T, but their null type can be tested with type()


Some data may be stored in custom containers defined as typed lists of type 16 (tlist) or 17 (matrix-oriented typed mlist). This is also the case for embedded types like (rationals), structures (struct), state-space, interactive trees (uitree), etc, for which type(..) will return 16 or 17. One will use typeof to get more information about their actual (sub)type.

Type conversion in mixed operations:

When a binary operator (like the multiplication) or an n-ary iterated one (like the concatenation) is applied beween two operands of distinct but compatible types, usually the type of one of both is implicitely converted, and the other operand sets the type of the result to its own type.

Examples with the concatenation : [%t, 3.124], [int8(5), 3.124], etc.

For the concatenation, addition, substraction, multiplication, division, and the power operation, the hierarchy between operands types is as follows (read "A < B": B imposes its type to A) :

  • boolean < (decimal number, complex encoded number)
  • (decimal number, complex-encoded number) < encoded integer.
  • polynomial (real | complex) < rational (real | complex)


// (Select some lines, right-click and choose "Execute.." to run the selection)
L = list(%pi,,"abc");
type(L(2))                  // undefined component of a list

type(42)                    // decimal numbers

type(1+%i)                  // complex numbers

s = sparse([1,2;4,5;3,10],[1,2,3]);
type(s)                     // sparse-encoded decimal or complex numbers

type(%t)                    // booleans

type(s>2)                   // sparse-encoded booleans

g = int8([1 -120 127 312]); // encoded integers
type(1.23 * int8(4))

type(1-%z+%z^2)             // polynomials

type(gdf())                 // graphic handles

type("foo")                 // texts

deff('[x] = mymacro(y,z)',['a=3*y+1'; 'x=a*z+y']);
type(mymacro)               // Scilab functions

type(disp)                  // Built-in functions

l = list(1,["a" "b"]);      // simple lists

e = tlist(["listtype","field1","field2"], [], []);
type(e)                     // Typed list

h = mlist(['V','name','value'],['a','b';'c' 'd'],[1 2; 3 4]);
type(h)                     // Typed matrix-oriented list

clear s, s.r = %pi          // structures

c = {%t %pi %i %z "abc" s}  // cells

r = [%z/(1-%z) (1-%z)/%z^2]
type(r)                     // rational fractions


  • The type 11 is removed. It was used for uncompiled Scilab functions.
  • type(:) now returns 129 instead of 1.
  • Assigning an object of type 0 to a variable no longer deletes this one.
Report an issue
<< tlist Estruturas de Dados typename >>

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 Feb 12 19:58:38 CET 2018