function csvwrite(filename, m, r, c)
%CSVWRITE Write a comma separated value file from a matrix.
%	CSVWRITE(FILENAME, M, R, C) writes matrix M into FILENAME, 
%	starting at offset row R, and column C in the file.
%	CSVWRITE(FILENAME, M) writes matrix M into FILENAME.
%	This is equivalent to R=C=0, since the upper left cell
%	in a spreadsheet is referenced by (0,0).
%	NOTE: Any elements whose value is 0 will be omitted.  For example,
%	The array [1 0 2] will appear in a file like '1,,2'.
%
%	See also CSVREAD, WK1READ, WK1WRITE.

%	Brian M. Bourgault 10/22/93
%	Copyright (c) 1984-94 by The MathWorks, Inc.
%

	%
	% test for proper filename
	%
	if ~isstr(filename)
		error('FILENAME must be a string.');
	end

	%
	% Call dlmwrite with a comma as the delimiter
	%
	if nargin < 3
		r = 0;
	end
	if nargin < 4
		c = 0;
	end
	dlmwrite(filename, m, ',', r, c);
