?? bits2nec_nasa.m
字號:
#!/usr/bin/octave -qH% -q causes Octave to run in 'quiet' mode, -H prevents the commands we use% from being added to Octave's command history.% function for converting a string which represents a binary number into a binary number% for speed we have no sanity checks. The number is read in the conventional sense (LSB on the RHS)function num = strbin (str) num = 0; len = max (size (str)); for i = 1:len num = num + (str (i) - '0') * bitshift (1, len - i); endendif (nargin < 1) fprintf (stderr, 'Usage: bits2nec_nasa.m <code> <code> <code>...\n'); exit (-1);endmax_length = 1;n_wire_segments = 100;diameter = 0.002;displacement = 0.002;frequency = 150;for N = 0 : length (argv) - 1 code = sscanf (nth (argv, N + 1), '%s'); nbits = max (size (code)); if mod (nbits, 24) ~= 0 fprintf (stderr, 'Error: arguments must be a multiple of 24 bits (it is %i)\n', nbits); exit (-1); end nsegments = nbits / 24; FILE = fopen (sprintf ('/tmp/horiz_%i.nec', N), 'w'); fprintf (FILE, 'CM Automatically-generated NEC script (from bits2nec_nasa_fast.m)\n'); fprintf (FILE, 'CE\n'); prev_p = [0; 0; 2 * displacement]; for i = 0:nsegments - 1 length = strbin (substr (code, 1 + i * 24, 8)); if (length == 0) length = 1; end theta = strbin (substr (code, 9 + i * 24, 8)); phi = strbin (substr (code, 17 + i * 24, 8)); p = [length * max_length / 256; 0; 0] + prev_p;% convert to radians theta = theta * pi / 256; phi = phi * 2 * pi / 256;% Generate coordinate transformation matrices (rotation about z and y axis) tmatrix = [cos(theta), -sin(theta), 0; sin(theta), cos(theta), 0; 0, 0, 1]* [cos(phi), 0, sin(phi); 0 ,1, 0; -sin(phi), 0, cos(phi)]; p = tmatrix * p; fprintf (FILE, 'GW %i %i %f %f %f %f %f %f %f\n', i + 1, n_wire_segments, prev_p (1), prev_p (2), prev_p (3), p(1), p(2), p(3), diameter); prev_p = p; end fprintf (FILE, 'GW %i 3 0 0 0 0 0 %f %f\n', nsegments, 2 * displacement, diameter); fprintf (FILE, 'GE\n'); for i = 1 : nsegments fprintf (FILE, 'LD %i 1 0 0 3.767E+07\n', i); end fprintf (FILE, 'EX %i 3 1 0 100\n', nsegments); fprintf (FILE, 'FR 0 1 0 0 %f\n', frequency); fclose (FILE); system (sprintf ('cp /tmp/horiz_%i.nec /tmp/vert_%i.nec', N, N)); FILE = fopen (sprintf ('/tmp/horiz_%i.nec', N), 'a'); fprintf (FILE, 'RP 0 1 360 0000 90 0 0 1\n'); fprintf (FILE, 'EN\n'); fclose (FILE); FILE = fopen (sprintf ('/tmp/vert_%i.nec', N), 'a'); fprintf (FILE, 'RP 0 360 1 0000 0 0 1 0\n'); fprintf (FILE, 'EN\n'); fclose (FILE);end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -