NTRUE

版本 1.0.0.0 (1.7 KB) 作者: Jos (10584)
Logical array with a specific number of true values
1.9K 次下载
更新时间 2006/9/15

查看许可证

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)

引用格式

Jos (10584) (2024). NTRUE (https://www.mathworks.com/matlabcentral/fileexchange/10924-ntrue), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R13
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Logical (Boolean) Operations 的更多信息
致谢

启发作品: randone1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0

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