function m = csvread(filename, r, c, rng)
%CSVREAD Read a comma separated value file.
%   M = CSVREAD(FILENAME) reads a comma separated value formatted file
%   FILENAME.  The result is returned in M.  The file can only contain
%   numeric values.
%
%   M = CSVREAD(FILENAME,R,C) reads data from the comma separated value
%   formatted file starting at row R and column C.  R and C are zero-
%   based so that R=0 and C=0 specifies the first value in the file.
%
%   M = CSVREAD(FILENAME,R,C,RNG) reads only the range specified
%   by RNG = [R1 C1 R2 C2] where (R1,C1) is the upper-left corner of
%   the data to be read and (R2,C2) is the lower-right corner.  RNG
%   can also be specified using spreadsheet notation as in RNG = 'A1..B7'.
%
%   See also CSVREAD, DLMREAD, DLMWRITE, WK1READ, WK1WRITE.

%   Brian M. Bourgault 10/22/93
%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 5.6 $  $Date: 1998/08/25 14:13:17 $

%
% test for proper filename
%
if ~isstr(filename)
    error('csvread: Filename must be a string argument!');
    return
end

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