Min and Max for Array

Find kth smallest or largest values and their indices.
513.0 次下载
更新时间 2012/7/27

查看许可证

MINMAX find kth smallest or largest values and their indices.

USAGE:
vals = minmax(data) % find minimum
vals = minmax(data,k) % find kth smallest values
vals = minmax(data,k,flag) % find kth largest values
[vals,loci] = minmax(:)
[vals,loci,locj] = minmax(:) for 2 d array
[vals,loci,locj,...] = minmax(:) % for multi dimensional array

INPUT:
data - two dimensional data
k - number of smallest or largest values required
flag - whether min or max

OUTPUT:
vals - smallest or largest values
loci - index to the row
locj - index to the column

EXAMPLES:
data = 1:16;
data = reshape(data,4,4);
[out,loci,locj] = minmax(data,5) % find the 5 smallest vaues and
their locations
[out,loci,locj] = minmax(data,5,'max) % find the 5 largest vaues and
their locations

引用格式

Durga Lal Shrestha (2024). Min and Max for Array (https://www.mathworks.com/matlabcentral/fileexchange/37646-min-and-max-for-array), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2010a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

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