open_beamlet_batch.m 824 B

1234567891011121314151617181920212223
  1. % Loads a beamlet batch into a cell array of sparse matrices
  2. function beamlets = open_beamlet_batch(batchname)
  3. fid = fopen(batchname,'rb');
  4. Nbeamlets = fread(fid,1,'int'); % number of beamlets in this file
  5. beamlets = cell(1,Nbeamlets);
  6. for k=1:Nbeamlets
  7. beamlets{k}.num = fread(fid,1,'int');
  8. beamlets{k}.x_count = fread(fid,1,'int');
  9. beamlets{k}.y_count = fread(fid,1,'int');
  10. beamlets{k}.z_count = fread(fid,1,'int');
  11. Nind = fread(fid,1,'int'); % number of non-zero values
  12. beamlets{k}.non_zero_indices = fread(fid,Nind,'int=>int');
  13. beamlets{k}.non_zero_values = fread(fid,Nind,'float=>float');
  14. % add unity to the indices to convert them from C to Matlab style
  15. % indexing:
  16. beamlets{k}.non_zero_indices = beamlets{k}.non_zero_indices + 1;
  17. % disp(int2str(k));
  18. end
  19. fclose(fid);