open_beamlet_batch_old.m 799 B

12345678910111213141516171819202122
  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. end
  18. fclose(fid);