View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Min and Max for Array

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 2.09 KB File ID: #37646 Version: 1.0
image thumbnail

Min and Max for Array

by

 

Find kth smallest or largest values and their indices.

| Watch this File

File Information
Description

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

Acknowledgements

This file inspired Transformation Matrix For Stress And Strain.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us