重叠高斯等间距网格的曲面图没有正确绘制?

时间:2018-05-25 18:14:23

标签: octave surface

我试图根据一堆重叠的偏移曲线在Octave中制作表面图。该函数应该相同地处理x和y,但我没有在最终的情节中看到它,而是沿着一个轴运行脊。我无法判断这是否是我的代码中的绘图错误或其他错误。我希望你能提供一些帮助/见解。

Plot with ridges following one axis

由于

clear;
graphics_toolkit gnuplot
V = 2500; %scan speed in mm
rr = 200000; %rep rate in Hz
Qsp = 1; %pulse energy
pi = 3.14159;
ns = 1; %scan number
w = 0.0125; %Gaussian radius in mm
dp = 0.0125; %lateral pulse distance in mm
dh = 0.0125; %hatch pitch in mm
xmax = 0.2; %ablation area x in mm
ymax = 0.2; %ablation area y in mm
np = round(xmax/dp); 
nh = round(ymax/dh);
points = 50;
cof = ns*2*Qsp/(pi*w^2);
N = [0:1:np];
M = rot90([0:1:nh]);
for i = 1:points
   for j = 1:points
    x = (i-1)*xmax/(points-1);
    y = (j-1)*ymax/(points-1);
    k = exp(-(2*(x-N*dp).^2+(y-M*dh).^2)/(w^2));
    H(i,j) = cof*sum(sum(k));
  endfor
endfor
ii = [1:1:points];
jj = ii;
xx = (ii-1)*xmax/(points-1);
yy = (jj-1)*ymax/(points-1);
surf(xx,yy,H);

1 个答案:

答案 0 :(得分:1)

我发现将复杂表达式的组件分开是有帮助的。

k = exp(-(2*(x-N*dp).^2+(y-M*dh).^2)/(w^2));

用这么多括号读起来太难了。

k = exp(
         -(
            2*(x-N*dp).^2  +  (y-M*dh).^2
          ) / (w^2)
       );

你看到了吗?

k = exp(
         -(
                2 * (x-N*dp).^2  
          +
                    (y-M*dh).^2
          ) / (w^2)
       );

x分量乘以2,但y分量不是。