Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

false

Logical 0 (false)

Syntax

Description

example

false is shorthand for the logical value 0.

example

F = false(n) is an n-by-n array of logical zeros.

example

F = false(sz) is an array of logical zeros where the size vector, sz, defines size(F). For example, false([2 3]) returns a 2-by-3 array of logical zeros.

example

F = false(sz1,...,szN) is a sz1-by-...-by-szN array of logical zeros where sz1,...,szN indicates the size of each dimension. For example, false(2,3) returns a 2-by-3 array of logical zeros.

example

F = false(___,'like',p) returns an array of logical zeros of the same sparsity as the logical variable p using any of the previous size syntaxes.

Examples

collapse all

Use false to generate a 3-by-3 square matrix of logical zeros.

A = false(3)
A =

  3×3 logical array

   0   0   0
   0   0   0
   0   0   0

class(A)
ans =

logical

The result is of class logical.

Use false to generate a 3-by-2-by-2 array of logical zeros.

false(3,2,2)
  3×2×2 logical array

ans(:,:,1) =

   0   0
   0   0
   0   0


ans(:,:,2) =

   0   0
   0   0
   0   0

Alternatively, use a size vector to specify the size of the matrix.

false([3 2 2])
  3×2×2 logical array

ans(:,:,1) =

   0   0
   0   0
   0   0


ans(:,:,2) =

   0   0
   0   0
   0   0

Note that specifying multiple vector inputs returns an error.

false along with true can be used to execute logic statements.

Test the logical statement

  ~(A and B) = (~A) or (~B)

for A = false and B = true.

~(false & true) == (~false) | (~true)
ans =

  logical

   1

The result is logical 1 (true), since the logical statements on both sides of the equation are equivalent. This logical statement is an instance of De Morgan's Law.

Generate a logical array of the same data type and sparsity as the selected array.

A = logical(sparse(5,3));
whos A
  Name      Size            Bytes  Class      Attributes

  A         5x3                41  logical    sparse    

F = false(4,'like',A);
whos F
  Name      Size            Bytes  Class      Attributes

  F         4x4                49  logical    sparse    

The output array F has the same sparse attribute as the specified array A.

Input Arguments

collapse all

Size of square matrix, specified as an integer. n sets the output array size to n-by-n. For example, false(3) returns a 3-by-3 array of logical zeros.

  • If n is 0, then F is an empty matrix.

  • If n is negative, then it is treated as 0.

Data Types: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Size vector, specified as a row vector of integers. For example, false([2 3)] returns a 2-by-3 array of logical zeros.

  • If the size of any dimension is 0, then F is an empty array.

  • If the size of any dimension is negative, then it is treated as 0.

  • If any trailing dimensions greater than 2 have a size of 1, then the output, F, does not include those dimensions.

Data Types: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Size inputs, specified by a comma-separated list of integers. For example, false(2,3) returns a 2-by-3 array of logical zeros.

  • If the size of any dimension is 0, then F is an empty array.

  • If the size of any dimension is negative, then it is treated as 0.

  • If any trailing dimensions greater than 2 have a size of 1, then the output, F, does not include those dimensions.

Data Types: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Prototype, specified as a logical variable.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Output of logical zeros, returned as a scalar, vector, matrix, or N-D array.

Data Types: logical

More About

collapse all

Tips

  • false(n) is much faster and more memory efficient than logical(zeros(n)).

See Also

|

Introduced before R2006a

Was this topic helpful?