Home > hfrc > matlab > @HFRC > sortS.m

# sortS

## PURPOSE SORTS - this function sorts data rows of an HFRC object

## SYNOPSIS function [ h, i, dist ] = sortS( h, p )

## DESCRIPTION ``` SORTS - this function sorts data rows of an HFRC object
spatially - i.e. by their grid coordinates.

Usage: [ hfrc2, indice, dist ] = sortS( hfrc, point );
[ hfrc2, indice, dist ] = sortS( hfrc, line );
[ hfrc2, indice ] = sortS( hfrc, str );

If the point argument is given, then data is sorted by distance from
the given point.  If it is left out, then they are just sorted
numerically - ie. first sorting by lat and then by lon.

If the line argument is given (a 2 row matrix with long as first column
and latitude as second column), then data is sorted by distance from
the line defined by the two points.  The dist output argument in this
case can be negative as explained in the dist_to_line function, even
though the sort carried out will actually be with respect to absolute
distance.

The dist output arguments are the distances in the same order as the
new HFRC object, hfrc2.

Alternativelly, a string can be given in place of point.  The str can
either be 'lat' or 'lon', indicating with respect to which component to
sort by.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\$Id: sortS.m,v 1.9 2003-06-17 02:05:38 dmk Exp \$

Copyright (C) 2001 David M. Kaplan
Licence: GPL

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%```

## CROSS-REFERENCE INFORMATION This function calls:
• end END - basic end method for HFRC objects.
• lonlat2km LONLAT2KM - Converts dimensions of totalGrid to kms from lon,lat
• size SIZE - returns [ (num times), (num gridpts) ].
• subsref SUBSREF Get HFRC elements easily
• dist DIST - computes distance in between points in euclidean space.
• dist_to_line DIST_TO_LINE - calculates distance a group of points is to a line.
This function is called by:
• format2_2hfrc FORMAT2_2HFRC - convert text total vector files (format 2) to HFRC
• format4_2hfrc FORMAT4_2HFRC - convert text total vector files (format 4) to HFRC

Generated on Mon 18-Dec-2006 07:26:46 by m2html © 2003