⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bits2nec_48.m

📁 在一个任意的天线方向图下
💻 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 ~= 2)	fprintf (stderr, 'Usage: bits2nec_48.m horiz | vert <code>\n');	exit (-1);endmax_length = 1;n_segments = 100;diameter = 0.002;displacement = 0.002;frequency = 150;hv = nth (argv, 1);code = sscanf (nth (argv, 2), '%s');if max (size (code)) ~= 48	fprintf (stderr, 'CATASTROPHE: code size is crazy? Should be 48, is %i\n', max (size (code)));	exit (-1);endi = 1;length1 = strbin (substr (code, i, 8));i += 8;th1 = strbin (substr (code, i, 8));i += 8;ph1 = strbin (substr (code, i, 8));i += 8;length2 = strbin (substr (code, i, 8));i += 8;th2 = strbin (substr (code, i, 8));i += 8;ph2 = strbin (substr (code, i, 8));if (~strcmp (hv, 'horiz') && ~strcmp (hv, 'vert'))	fprintf (stderr, 'Usage: bits2nec_48.m horiz | vert <code>\n');	exit (-2);endif (length1 == 0)	length1 = 1;endif (length2 == 0)	length2 = 1;endprintf ('CM Automatically-generated NEC script (from bits2nec_48.m)\n');printf ('CE\n');p1 = [length1 * max_length / 256; 0; 0];p2 = [-length2 * max_length / 256; 0; 0];% convert to angles in radiansfprintf (stderr, 'th1 = %i, ph1 = %i, th2 = %i, ph2 = %i\n', th1, ph1, th2, ph2);th1 = th1 * pi / 256;ph1 = ph1 * 2 * pi / 256;th2 = th2 * pi / 256;ph2 = ph2 * 2 * pi / 256;fprintf (stderr, 'th1 = %f, ph1 = %f, th2 = %f, ph2 = %f\n', th1, ph1, th2, ph2);% Generate coordinate transformation matrices (rotation about z and y axis)tmatrix1 = [cos(th1), -sin(th1), 0; sin(th1), cos(th1), 0; 0, 0, 1]* [cos(ph1), 0, sin(ph1); 0 ,1, 0; -sin(ph1), 0, cos(ph1)];tmatrix2 = [cos(th2), -sin(th2), 0; sin(th2), cos(th2), 0; 0, 0, 1]* [cos(ph2), 0, sin(ph2); 0 ,1, 0; -sin(ph2), 0, cos(ph2)];% Calculate new points p1 and p2p1 = tmatrix1 * p1;p2 = tmatrix2 * p2;%segment = floor (((length1 / (cos(ph1) * sin(th1))) / (length1 / (cos(ph1) * sin(th1)) + length2 / (cos(ph2) * sin(th2))) * n_segments) + 1;printf ('GW 1 %i %f 0 0 %f %f %f %f\n', n_segments, displacement, p1(1), p1(2), p1(3), diameter);printf ('GW 2 %i %f 0 0 %f %f %f %f\n', n_segments, -displacement, p2(1), p2(2), p2(3), diameter);printf ('GW 3 3 %f 0 0 %f 0 0 %f\n', -displacement, displacement, diameter);printf ('GE\n');printf ('LD 5 1 0 0 3.767E+07\n');printf ('LD 5 2 0 0 3.767E+07\n');printf ('LD 5 3 0 0 3.767E+07\n');printf ('EX 0 3 1 0 100\n');printf ('FR 0 1 0 0 %f\n', frequency);if (strcmp (hv, 'horiz'))	printf ('RP 0 1 360 0000 90 0 0 1\n');else	printf ('RP 0 360 1 0000 0 0 1 0\n');endprintf ('EN\n');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -