function [] = csvwrite (file, data, sep)
% [] = csvwrite (file, data, [sep])
%
% Write CSV file
%
% file: file name
% data: matrix of data
% sep: separator character [',']

  % check parameters
  if nargin < 3
    sep = ',';
  end

  % open file
  fid = fopen(file, 'wt');
  if ~fid
    error ('can''t open file %s', file);
  end

  % write data
  for i=1:rows(data),
    fprintf (fid, '%g', data(i, 1));
    fprintf (fid, [sep '%g'], data(i, 2:end));
    fprintf (fid, '\n');
  end

  % close file
  fclose (fid);

% Author: Laurent Mazet
% Email: mazet@softndesign.org
% Date: 2/3/2008

% Local Variables: **
% mode: Matlab **
% End: **