Program Examples:Sci Lab interface/zh-hans

From SoftMC-Wiki
< Program Examples:Sci Lab interface
Revision as of 07:32, 17 July 2017 by Chi (talk | contribs) (Created page with "{{Languages}} Example for function of reading softMC record file from SciLab (64bit). <syntaxhighlight lang="scilab"> global rec rec = []; function MCplot(name) global rec...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
语言: [[::Program Examples:Sci Lab interface|English]]  • [[::Program Examples:Sci Lab interface/zh-hans|中文(简体)‎]]

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')
parm3d(rec(:,1),rec(:,2),rec(:,3));