0001 function new_chdr = concat_csdm_chdr(csdmfiles, obs)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 csdm_hdr_offsets_v;
0013
0014 csdm_fid = fopen(csdmfiles(1,:),'r');
0015 [csdm_fhdr,csdm_chdr]=rd_csdm_hdr_v(csdm_fid);
0016 fclose(csdm_fid);
0017
0018 num_files = size(csdmfiles,1);
0019
0020 if nargin == 2 & num_files > 1
0021 if length(obs) > 1
0022 disp('Warning: Multiple files, multiple observations')
0023 disp('To have proper headers, either specify one observation, or use all, dammit!')
0024 end
0025 else
0026 obs = 1:csdm_chdr(1,NObs);
0027 end
0028
0029 num_obs = length(obs);
0030
0031
0032 new_chdr = csdm_chdr(:,1:5);
0033
0034 for f = 1:size(csdmfiles,1)
0035 csdm_fid = fopen(csdmfiles(f,:),'r');
0036 [csdm_fhdr,csdm_chdr]=rd_csdm_hdr_v(csdm_fid);
0037 fclose(csdm_fid);
0038
0039 last_col = size(new_chdr,2);
0040 num_new_col = num_obs * csdm_chdr(1,LSpec)/2;
0041 if num_obs > 1
0042 new_chdr(:,last_col+1:last_col+num_new_col) = csdm_chdr(:,6:5+num_new_col);
0043 else
0044 spec_start = 6+(obs-1)*num_new_col;
0045 spec_stop = 5 + (obs)*num_new_col;
0046 new_chdr(:,last_col+1:last_col+num_new_col) = csdm_chdr(:,spec_start:spec_stop);
0047 end
0048 end
0049
0050 return