diff -Naur --exclude Makefile --exclude info wfdb-10.5.21/app/snip.c wfdb-10.5.22/app/snip.c
--- wfdb-10.5.21/app/snip.c	2012-03-21 00:49:45.000000000 -0400
+++ wfdb-10.5.22/app/snip.c	2013-12-01 14:18:00.000000000 -0500
@@ -1,8 +1,8 @@
 /* file: snip.c		G. Moody	30 July 1989
-			Last revised:	20 March 2012
+			Last revised:  1 December 2013
 -------------------------------------------------------------------------------
 snip: Copy an excerpt of a database record
-Copyright (C) 1989-2012 George B. Moody
+Copyright (C) 1989-2013 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -29,6 +29,7 @@
 #include <wfdb/wfdblib.h>
 
 char *pname;
+int fmt = 0;	/* use specified output format if fmt > 0 */
 int mflag = 0;	/* try to preserve segments if non-zero */
 int sflag = 0;	/* suppress copying info if non-zero */
 
@@ -87,6 +88,10 @@
 	    irec = argv[i];
 	    break;
 	  case 'l':	/* length of snip */
+	    if (++i >= argc) {
+		(void)fprintf(stderr, "%s: duration must follow -l\n", pname);
+		exit(1);
+	    }
 	    length = argv[i];
 	    break;
 	  case 'm':  /* preserve segments of multisegment input, if possible */
@@ -100,6 +105,15 @@
 	    }
 	    nrec = argv[i];
 	    break;
+	  case 'O':	/* output format */
+	    if (++i >= argc) {
+		(void)fprintf(stderr, "%s: output format must follow -O\n",
+			      pname);
+		exit(1);
+	    }
+	    fmt = strtol(argv[i], NULL, 10);
+	    break;
+	    
 	  case 's':	/* suppress copying of info */
 	    sflag = 1;
 	    break;
@@ -225,7 +239,7 @@
 void copy_sig(char *nrec, char *irec, WFDB_Time from, WFDB_Time to, int recurse)
 {
     char *ofname, *p, tstring[24];
-    int i, j, nsig, maxseg, maxres, fmt;
+    int i, j, nsig, maxseg, maxres;
     long nsamp;
     WFDB_Sample *v;
     WFDB_Siginfo *si;
@@ -367,29 +381,29 @@
 	return;
     }
 
-    /* Choose an output format */
-    maxres = si[0].adcres;
-    fmt = si[0].fmt;
-    for (i = 1; i < nsig; i++) {
-	if (si[i].adcres > maxres)
-	    maxres = si[i].adcres;
-	if (si[i].fmt != fmt)
-	    fmt = 0;
-    }
-
-    if (fmt == 0) {
-	if (maxres > 24)
-	    fmt = 32;
-	else if (maxres > 16)
-	    fmt = 24;
-	else if (maxres > 12)
-	    fmt = 16;
-	else if (maxres > 10)
-	    fmt = 212;
-	else if (maxres > 8)
-	    fmt = 310;
-	else
-	    fmt = 80;
+    if (fmt <= 0) { /* no -O option, choose format based on ADC resolution */
+	maxres = si[0].adcres;
+	fmt = si[0].fmt;
+	for (i = 1; i < nsig; i++) {
+	    if (si[i].adcres > maxres)
+		maxres = si[i].adcres;
+	    if (si[i].fmt != fmt)
+		fmt = 0;
+	}
+	if (fmt == 0) {
+	    if (maxres > 24)
+		fmt = 32;
+	    else if (maxres > 16)
+		fmt = 24;
+	    else if (maxres > 12)
+		fmt = 16;
+	    else if (maxres > 10)
+		fmt = 212;
+	    else if (maxres > 8)
+		fmt = 310;
+	    else
+		fmt = 80;
+	}
     }
 
     /* Open the output signals. */
@@ -473,9 +487,11 @@
  " -h          print this usage summary",
  " -l DURATION snip only DURATION (hh:mm:ss or sNNNN; overrides -t)",    
  " -m          preserve segments of multsegment input, if possible",
+ " -O FORMAT   save output in the specified FORMAT (default: use best fit",
+ "              to ADC resolution)",
  " -s          suppress output of info strings in header",
  " -t TIME     stop at specified time",
- "To change the sampling frequency, gain, or storage format, to select a",
+ "To change the sampling frequency, zero level, or gain, to select a",
  "subset of signals, or to re-order signals, use `xform'.",
 NULL
 };
diff -Naur --exclude Makefile --exclude info wfdb-10.5.21/convert/wfdb2mat.c wfdb-10.5.22/convert/wfdb2mat.c
--- wfdb-10.5.21/convert/wfdb2mat.c	2013-01-02 17:54:06.000000000 -0500
+++ wfdb-10.5.22/convert/wfdb2mat.c	2013-12-08 11:53:54.000000000 -0500
@@ -1,5 +1,5 @@
 /* file: wfdb2mat.c	G. Moody	26 February 2009
-			Last revised:	 2 January 2013
+			Last revised:	 8 December 2013
 -------------------------------------------------------------------------------
 wfdb2mat: Convert (all or part of) a WFDB signal file to Matlab .mat format
 Copyright (C) 2009-2013 George B. Moody
@@ -272,7 +272,16 @@
 	so[i].group = 0;
 	so[i].spf = 1;
 	so[i].fmt = wfdbtype;
-	if (so[i].units == NULL) SSTRCPY(so[i].units, "mV");
+	/* handle possibly missing units strings */
+	if (so[i].units == NULL) {
+	    /* in a .hea file, missing units can be assumed to be millivolts */
+	    SSTRCPY(so[i].units, "mV");
+	}
+	else if (strlen(so[i].units) == 0) {
+	    /* this can happen only in an EDF file; in this case, the signal
+	       is dimensionless (nd => "no dimension") */
+	    SSTRCPY(so[i].units, "nd");
+	}
     }
 
     /* Create an empty .mat file. */
diff -Naur --exclude Makefile --exclude info wfdb-10.5.21/doc/wag-src/snip.1 wfdb-10.5.22/doc/wag-src/snip.1
--- wfdb-10.5.21/doc/wag-src/snip.1	2009-04-17 01:16:23.000000000 -0400
+++ wfdb-10.5.22/doc/wag-src/snip.1	2013-12-01 14:24:53.000000000 -0500
@@ -1,4 +1,4 @@
-.TH SNIP 1 "17 Aril 2009" "WFDB 10.4.20" "WFDB Applications Guide"
+.TH SNIP 1 "1 December 2013" "WFDB 10.5.21" "WFDB Applications Guide"
 .SH NAME
 snip \- copy an excerpt of a WFDB record
 .SH SYNOPSIS
@@ -12,7 +12,7 @@
 .PP
 The program \fBxform\fR(1) can also perform this task, but offers additional
 flexibility (it can scale the signals, resample them at a different frequency,
-rearrange them, select subsets of them, or reformat them);  \fIsnip\fR is
+rearrange them, select subsets of them, or reformat them);  \fBsnip\fR is
 faster than \fBxform\fR, however.
 .PP
 \fIOptions\fR are:
@@ -38,6 +38,11 @@
 \fB-m\fR
 Preserve segments of multi-segment input, if possible.
 .TP
+\fB-O\fR \fIformat\fR
+Write output in the specified \fIformat\fR.  See \fBheader\fR(5) for a list of
+available formats (16, 80, 212, ...).  If this option is omitted, \fBsnip\fR
+uses a format that best fits the ADC resolution of the samples.
+.TP
 \fB-s\fR
 Suppress output of info strings in the output header file.
 .TP
@@ -59,7 +64,7 @@
 \fInew-record\fR.hea
 output header file
 .SH SEE ALSO
-\fBsetwfdb\fR(1), \fBxform\fR(1)
+\fBsetwfdb\fR(1), \fBxform\fR(1), \fBheader\fR(5)
 .SH AUTHOR
 George B. Moody (george@mit.edu)
 .SH SOURCE
diff -Naur --exclude Makefile --exclude info wfdb-10.5.21/doc/wag-src/wfdb2mat.1 wfdb-10.5.22/doc/wag-src/wfdb2mat.1
--- wfdb-10.5.21/doc/wag-src/wfdb2mat.1	2013-08-29 08:27:14.000000000 -0400
+++ wfdb-10.5.22/doc/wag-src/wfdb2mat.1	2013-12-08 12:13:56.000000000 -0500
@@ -1,4 +1,4 @@
-.TH WFDB2MAT 1  "16 March 2010" "WFDB 10.5.0" "WFDB Applications Guide"
+.TH WFDB2MAT 1  "8 December 2013" "WFDB 10.5.22" "WFDB Applications Guide"
 .SH NAME
 wfdb2mat \- convert WFDB-compatible signal file to Matlab .mat file
 .SH SYNOPSIS
@@ -98,6 +98,13 @@
 .br
 (Download \fBhttp://physionet.org/physiotools/matlab/plotATM.m\fR and install
 it in your Matlab or Octave environment first.)
+.PP
+Note that when EDF (or EDF+, BDF, or BDF+) files are used as input, they may
+have empty 'physical dimension' (units) fields, which imply that the associated
+signals are dimensionless (for example, they may be event markers or categorical
+variables).  In such cases, \fBwfdb2mat\fR records the signal units as \fBnd\fR
+(no dimension).
+
 .SH ENVIRONMENT
 .PP
 It may be necessary to set and export the shell variable \fBWFDB\fR (see
diff -Naur --exclude Makefile --exclude info wfdb-10.5.21/lib/wfdb.h wfdb-10.5.22/lib/wfdb.h
--- wfdb-10.5.21/lib/wfdb.h	2013-11-21 10:26:25.000000000 -0500
+++ wfdb-10.5.22/lib/wfdb.h	2013-12-08 12:14:30.000000000 -0500
@@ -32,7 +32,7 @@
 /* WFDB library version. */
 #define WFDB_MAJOR   10
 #define WFDB_MINOR   5
-#define WFDB_RELEASE 21
+#define WFDB_RELEASE 22
 #define WFDB_NETFILES 1	/* if 1, library includes code for HTTP, FTP clients */
 #define WFDB_NETFILES_LIBCURL 1
 
diff -Naur --exclude Makefile --exclude info wfdb-10.5.21/NEWS wfdb-10.5.22/NEWS
--- wfdb-10.5.21/NEWS	2013-11-21 18:28:13.046204780 -0500
+++ wfdb-10.5.22/NEWS	2013-12-08 13:52:31.128441279 -0500
@@ -1,3 +1,11 @@
+10.5.22 (8 December 2013):
+	'snip' has a new '-O' option to select the output format, and the '-l'
+	option to specify the duration now works properly.
+
+	wfdb2mat (convert/wfdb2mat.c) now ensures that all output signals have
+	non-empty units strings (previous versions did not check for this
+	possibility when the input was an EDF or EDF+ file).
+
 10.5.21 (21 November 2013):
 	This release is the first to pass all tests performed by 'make check'
 	when compiled on MS-Windows using MinGW.  Changes in 'configure',
