function brukout2dtimev1(inc,ins,nt1,nt2,outname)
% *** output 2D time data to .bruker format (spit from RNMR) *** 
% Y. Matsuki, January, 2009
% Y. Matsuki, August, 2009
% usage:
% brukout3dtimev1(incc,insc,incs,inss,nt1,nt2,nt3,outname)
% ========================================================
% need to do bin2pipe for a subsequent pipe processing.

% this worked on ym mac.
% data order is platform dependent? or pipe version dependent???
% if so, too bad...

% aug2709.
% modified from binout3dtime.m
% Because output of binout2dtime.m cannot convert correctly to pipe format
% by bin2pipe function, trying this way. Output to same exact format to
% .bruker file spit from RNMR, then convert it to pipe format with xxx.csh
% script, which is bruk2pipe function, which has been 
% already confirmed that it works well on my macPro (Osaka).

% aug2809. same thing for 2D data.

% used:
% bk_mar1611soReverse600.m

out=zeros(nt2*2,nt1*2);
l=1;
% for p=1:nt2
for n=1:nt1
    k=1;
    for m=1:nt2
        out(k,l)=real(inc(m,n));
        k=k+1;
        out(k,l)=imag(inc(m,n));
        k=k+1;
    end
    l=l+1;

    k=1;
    for m=1:nt2
        out(k,l)=real(ins(m,n));
        k=k+1;
        out(k,l)=imag(ins(m,n));
        k=k+1;
    end
    l=l+1;
end

% p
% end

% out(1,1)
% out(2,1)
% fid=fopen(outname,'w','l');
fid=fopen(outname,'wb'); % worked for bignohsqc_005 and ccr5p 8/28/09
% fid=fopen(outname,'w','n'); % 

fseek(fid,0,'bof');
% fwrite(fid,out,'float32');
fwrite(fid,out,'integer*4');% worked for bignohsqc_005 and ccr5p 8/28/09
% fwrite(fid,out,'uint32');% 
fclose(fid);
    disp('---> time data output is done.')

    
    
    
    
    