isprime
Determine which array elements are prime
Syntax
Description
Examples
Determine if Double Integer Values Are Prime
tf = isprime([2 3 0 6 10])
tf = 1x5 logical array
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 = 1x3 logical array
0 1 0
71
is prime, but 333
and 99
are not.
Input Arguments
X
— Input values
scalar, 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
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
The maximum double precision input is
2^33
.The maximum single precision input is
2^25
.The input
X
cannot have typeint64
oruint64
.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced before R2006a
Beispiel öffnen
Sie haben eine geänderte Version dieses Beispiels. Möchten Sie dieses Beispiel mit Ihren Änderungen öffnen?
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)