0

我是 scilab 的新手,编写一个简单的函数会引发语法错误,这对我完全没有帮助。

Error: syntax error, unexpected endfunction, expecting end of file

有人可以指出我的错误,对我来说一切都很好。

function miescattering(m,x)
nmax=round(2+x+4*x^(1/3))
n=(1:nmax); nu = (n+0.5); z=m.*x; m2=m.*m
sqx= sqrt(0.5*pi./x); sqz= sqrt(0.5*pi./z)
bx = besselj(nu, x).*sqx
bz = besselj(nu, z).*sqz
yx = bessely(nu, x).*sqx
hx = bx+i*yx
b1x=[sin(x)/x, bx(1:nmax-1)]
b1z=[sin(z)/z, bz(1:nmax-1)]
y1x=[-cos(x)/x, yx(1:nmax-1)]
h1x= b1x+i*y1x
ax = x.*b1x-n.*bx
az = z.*b1z-n.*bz
ahx= x.*h1x-n.*hx
an = (m2.*bz.*ax-bx.*az)./(m2.*bz.*ahx-hx.*az)
end
plot (x,an)
title ("mie scattering coefficients")
xlabel("x")
ylabel("cofficient")
endfunction
4

0 回答 0