Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2024.1.0 - English


ismatrix

checks if an object is a non-empty 1D or 2D matrix or array

Syntax

tf = ismatrix(x)

Arguments

x

scalar,vector, matrix, hypermatrix, list, array of structures or of cells

tf

a boolean

Description

ismatrix(x) returns %T (true) if x is a scalar (single component), or a vector or a matrix or array with one or 2 dimensions.

  • An hypermatrix that would be a matrix after reordering its dimensions is considered as a matrix.
  • To test that x is not an hypermatrix or an hyperarray -- whatever are the sizes of its dimensions --, use simply ndims(x)<3.
  • ismatrix([]) returns false.

Examples

ismatrix(ones(10,5))
ismatrix(1)
ismatrix(["s" "t" "u"; "t" "s" "u"])
ismatrix(rand(2,1,3)) //because of singleton
ismatrix(rand(2,2,3)) //hypermatrix
s = struct();
ismatrix(s) // Empty structure
clear s
s(1,2).a = 3;
s(1,3).b = %z;
ismatrix(s) // Row array of structures
clear s
s(2,1).a = "w";
s(3,1).b = %t;
iscolumn(s) // Column array of structures
clear s
s(1,2).a = -2;
s(3,1).b = %pi;
ismatrix(s) // 2D not-square array of structures
clear s
s(2,1,2).a = 3;
s(1,1,2).b = "test";
ismatrix(s) // 3D array of structures (with a singleton dim)
clear s
s(1,1,2).a = 3;
s(1,1,3).b = "test";
ismatrix(s) // 3D array of structures (with 2 singleton dims)
clear s
s(2,2,2).a = %f;
s(1,2,1).b = list(%e, %s);
ismatrix(s) // 3D (cubic) array of structures

See also

  • isscalar — check if a variable is a scalar.
  • isrow — check if a variable is a row
  • iscolumn — check if a variable is a column
  • issquare — check if a variable is a square matrix
  • isempty — check if a variable is an empty matrix or an empty list
  • ndims — number of dimensions of an array

History

VersionDescription
5.5.0 Function ismatrix introduced.
Report an issue
<< iscolumn Shape tests isrow >>

Copyright (c) 2022-2024 (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 Jun 17 17:49:15 CEST 2024