NTRUE

Logical array with a specific number of true values
1,9K téléchargements
Mise à jour 15 sept. 2006

Afficher la licence

NTRUE - Logical array with a specific number of true values
NTRUE(N,P,Q, ...) or NTRUE(N,[P Q ...]) creates a logical array of size
[P Q ...] with N randomly positioned true values. NTRUE(N,P) is short for
NTRUE(N,P,P). All arguments (N,P,Q,...) are positive scalars.

NTRUE(N) creates a N-ny-N matrix with N true values.

Example:
NTRUE(5,3,4) % creates a 3-by-4 matrix with 5 true (and 7 false)
values, for instance:
% 0 0 0 0
% 1 1 0 0
% 1 0 1 1

See also TRUE, FALSE, ONES, ZEROS,
and SLM, SHAKE, NONES (on the MatLab FEX)

Citation pour cette source

Jos (10584) (2026). NTRUE (https://fr.mathworks.com/matlabcentral/fileexchange/10924-ntrue), MATLAB Central File Exchange. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R13
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Logical (Boolean) Operations dans Help Center et MATLAB Answers
Remerciements

A inspiré : randone1

Version Publié le Notes de version
1.0.0.0

(sep 2006)
- algorithm after all checks
- replaced call to randperm by a direct call to sort