function writeraw(filename,data,precision,head,tail,skip,mach,bskip)

if nargin<=2 
  precision=['unsigned char'];
  head=[];
  tail=[];
  skip=0;
  mach='ieee-le';
  bskip=0;
elseif nargin<=3 
  head=[];
  tail=[];
  skip=0;
  mach='ieee-le';
  bskip=0;
elseif nargin<=4
  tail=[];
  skip=0;
  mach='ieee-le';
elseif nargin<=5
  skip=0;
  mach='ieee-le';
  bskip=0;
elseif nargin<=6
  mach='ieee-le';
  bskip=0;
elseif nargin<=7
  bskip=0;
end

if (~isempty(head) & head==0)
  disp('Warning head should = [] for no head');
end
if (~isempty(tail) & tail==0 )
  disp('Warning tail should = [] for no head');
end


fid=fopen(filename,'w',mach);
%disp(['skiping ' num2str(skip) ' bytes']);  
fseek(fid,skip,0);
fwrite(fid,zeros(1,bskip),'ubit1');
fwrite(fid,head,'char');
fwrite(fid,data,precision);
fwrite(fid,tail,'char');
fclose(fid);

