matlab求助:arrayfun函数inline type is not currently implemented.
clear allsyms s1 s2 zz lamda bata c a w;%variance and parameter
z=50:300;
k=2*pi/lamda;
rho=(0.545*c^2*k^2*zz)^(3/5);
f1=k^2/(zz^2)*s1*s2;
f2=exp(j*k/(2*zz)*(s1^2-s2^2))*exp(-1/rho^2*(s1^2+s2^2))*besseli(0,2*s1*s2/rho^2);
f3=besselj(0,bata*s1)*besselj(0,bata*s2);
f4=exp(-(s1-a)^2/w^2)*exp(-(s2-a)^2/w^2);
f=f1*f2*f3*f4;%integrand
f=subs(f,{lamda,bata,c,a,w},{1550*10^-9,300,10^-14,0.03,0.03});
fstr=char(vectorize(inline(f)));% character string
fstr=sprintf('dblquad(inline(%s),0.03,1,0.03,1)',fstr);
fun=inline(fstr,'s1','s2','zz');
Z=arrayfun(@(zz)fun,z);
plot(z,abs(Z))
下面是出现的问题:
??? Error using ==> arrayfun
inline type is not currently implemented.
Error in ==> axialintensity at 16
Z=arrayfun(@(zz)fun,z);恳请指教,谢谢!
[ 本帖最后由 sigma665 于 2008-9-23 10:54 编辑 ] doc arrayfun
看看其用法 看了半天,不会 不是arrayfun的问题。而是你的这个inline函数fun本身构造的就不对。
回复 板凳 sigma665 的帖子
clear allsyms s1 s2 zz lamda bata c a w;%变量和参数
z=50:300;
k=2*pi/lamda;
rho=(0.545*c^2*k^2*zz)^(-3/5);
f1=k^2/(zz^2)*s1*s2;
f2=exp(j*k/(2*zz)*(s1^2-s2^2))*exp(-1/rho^2*(s1^2+s2^2))*besseli(0,2*s1*s2/rho^2);
f3=besselj(0,bata*s1)*besselj(0,bata*s2);
f4=exp(-(s1-a)^2/w^2)*exp(-(s2-a)^2/w^2);
f=f1*f2*f3*f4;%这是被积函数的符号表达式,当然可以换一个比较简单的函数。变量为是s1
s2还有参数 zz,目的是对s1和s2积分,做出积分值与zz的曲线。
f=subs(f,{lamda,bata,c,a,w},{1550*10^-9,300,10^-14,0.03,0.03});% 代入参数值
fstr=char(vectorize(inline(f)));% 为了适用dblquad ,将被函数变为字符表达式
fstr=sprintf('dblquad(inline(%s),0.03,1,0.03,1)',fstr);
fun=inline(fstr,'s1','s2','zz');
Z=arrayfun(@(zz)fun,z);
plot(z,abs(Z))
[ 本帖最后由 soberprogress 于 2008-9-24 15:25 编辑 ] 本帖最后由 Happy99 于 2010-12-12 22:46 编辑
rocwoods 发表于 2008-9-24 11:23 http://www.chinavib.com/static/image/common/back.gif
...这个inline函数fun本身构造的就不对。不清楚这个意思!?
"inline type is not currently implemented."的意思, 不是说arrayfun不适用inline type的型态?
inline用的不对
这个应该可以用匿名函数来写的,对现在的版本来说,可以用quad2d来求积分 {:{23}:} thanks!
页:
[1]