Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

isprime

Determine which array elements are prime

Syntax

Description

example

TF = isprime(X) returns a logical array the same size as X. The value at TF(i) is true when X(i) is a prime number. Otherwise, the value is false.

Examples

expand all

Determine if Double Integer Values Are Prime

tf = isprime([2 3 0 6 10])
tf =

     1     1     0     0     0

2 and 3 are prime, but 0, 6, and 10 are not.

Determine if Unsigned Integer Values Are Prime

x = uint16([333 71 99]);
tf = isprime(x)
tf =

     0     1     0

71 is prime, but 333 and 99 are not.

Input Arguments

expand all

X — Input valuesscalar, vector, or array of real, nonnegative integer values

Input values, specified as a scalar, vector, or array of real, nonnegative integer values.

Example: 17

Example: [1 2 3 4]

Example: int16([127 255 4095])

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

See Also

|

Was this topic helpful?