Program Examples:Sci Lab interface

From SoftMC-Wiki
Jump to: navigation, search
Language: English  • 中文(简体)‎

Example for function of reading softMC record file from SciLab (64bit).

global rec 
rec = [];

function MCplot(name)
global rec
     fid = mopen(name,'rb');
     n   = mget(1,'i',fid);
     m   = mget(1,'i',fid);
     gap = mget(1,'i',fid);
     vlen= mget(1,'i',fid);
     var = mgetstr(vlen,fid);
     n = modulo(n,16);
     rec = zeros(m,n);
          
     for i = 1:m
       for j = 1:n
     	 tmp = mget(1,'d',fid);
     	 rec(i,j) = tmp;
     	end
     end
     mclose(fid);
endfunction
  • 32bit version is the same just instead "i" identifier in mget the "l" identifier is used.

The function is invoked as (draws 3D trajectory) :

MCplot('C:\SoftMC\Projects\test.rec')
param3d(rec(:,1),rec(:,2),rec(:,3));