0001 function [csdm_data, csdm_fhdr, csdm_chdr] = read_csdm(csdm_fname, cell, obs)
0002
0003
0004
0005 size_data_type = 4;
0006
0007 if nargin < 3
0008 error('Need 3 input arguments');
0009 end
0010
0011 if length(cell) > 1
0012 error('Only one cell can be specified at a time');
0013 end
0014
0015 if length(obs) > 1
0016 error('Only one observation can be specified at a time');
0017 end
0018
0019
0020
0021 csdm_fid = fopen(csdm_fname, 'rb');
0022
0023
0024
0025 ave_hdr_offsets_v;
0026
0027 [csdm_fhdr,csdm_chdr,ename,czeros,cgains,cnames,fcom,ftext, coff]=rd_csdm_hdr_v(csdm_fid);
0028
0029 [cell_data_offsets]=get_csdm_cell_off(csdm_fhdr, csdm_chdr);
0030
0031
0032
0033 foffset = cell_data_offsets(cell) + (obs-1)*csdm_fhdr(NChan)*csdm_chdr(cell,NPoints)*size_data_type;
0034
0035 fseek(csdm_fid, foffset, 'bof');
0036
0037 real_csdm_data = fread(csdm_fid, [csdm_fhdr(NChan) csdm_chdr(cell, NPoints)/2], 'float');
0038
0039 imag_csdm_data = fread(csdm_fid, [csdm_fhdr(NChan) csdm_chdr(cell, NPoints)/2], 'float');
0040
0041 csdm_data = real_csdm_data' + imag_csdm_data'*i;
0042
0043 fclose(csdm_fid);