yexuehua 发表于 2006-3-15 12:59

[求助]本人新手,关于数值积分的问题,急!希望得到各位大侠帮助

<P>function f=rw0(cet2,lamd)<BR>global z r <BR>n2=1.53974+0.0045628./(lamd).^2;<BR>k1=2.*pi./lamd;<BR>k3=k1;<BR>k2=2.*n2.*pi./lamd;<BR>det=2.*pi.*n2.*200./lamd;<BR>cet3=asin(n2.*sin(cet2));<BR>t1p=2./(n2+1);<BR>t2p=2.*n2.*cos(cet2)./(cos(cet2)+n2.*cos(cet3));<BR>r1p=(n2-1)./(n2+1);<BR>r2p=(n2.*cos(cet2)-cos(cet3))./(n2.*cos(cet2)+cos(cet3));<BR>t=t1p.*t2p.*exp(i.*det)./(1+r1p.*r2p.*exp(2.*i.*det));<BR>f=i.*t.*sqrt(cos(cet2)).*sin(cet2).*cos(cet3).*besselj(1,k2.*r.*sin(cet2)).*exp(i.*k3.*z.*cos(cet3)); <BR><BR>function f=rw1(cet2,lamd)<BR>global z r<BR>n2=1.53974+0.0045628./(lamd).^2;<BR>k1=2.*pi./lamd;<BR>k3=k1;<BR>k2=2.*n2.*pi./lamd;<BR>det=2.*pi.*n2.*200./lamd;<BR>cet3=asin(n2.*sin(cet2));<BR>t1p=2./(n2+1);<BR>t2p=2.*n2.*cos(cet2)./(cos(cet2)+n2.*cos(cet3));<BR>r1p=(n2-1)./(n2+1);<BR>r2p=(n2.*cos(cet2)-cos(cet3))./(n2.*cos(cet2)+cos(cet3));<BR>t=t1p.*t2p.*exp(i.*det)./(1+r1p.*r2p.*exp(2.*i.*det));<BR>f=2.*t.*sqrt(cos(cet2)).*sin(cet2).*sin(cet3).*besselj(0,k2.*r.*sin(cet2)).*exp(i.*k3.*z.*cos(cet3));<BR><BR>function f=rw2(lamd)<BR>global z r <BR>tol=1e-6;<BR>    Er=quad(@rw0,1e-15,pi./4,tol,[],lamd);<BR>    Ez=quad(@rw1,1e-15,pi./4,tol,[],lamd);<BR>    E2=abs(Ez).^2;<BR>    E1=abs(Er).^2;<BR>    E=E1+E2;<BR>    f=exp(-(lamd-0.55).^2).*E<BR><BR>clear<BR>global z r<BR>z=0;<BR>xx=-0.8;sx=0.8;<BR>for j1=1:101<BR>    r=xx+(j1-1).*(sx-xx)./100;<BR>    I=quad(@rw2,0.545,0.555);<BR>    rx(j1)=r;<BR>end<BR>plot(rx,I./max(max(I)),'k')<BR>显示结果为:<BR>??? Error using ==&gt; .*<BR>Matrix dimensions must agree.</P>
<P>Error in ==&gt; E:\雪华\dispersive\rw0.m<BR>On line 8==&gt; cet3=asin(n2.*sin(cet2));</P>
<P>Error in ==&gt; E:\雪华\toolbox\matlab\funfun\quad.m (quadstep)<BR>On line 114==&gt; y = feval(f, x, varargin{:});</P>
<P>Error in ==&gt; E:\雪华\toolbox\matlab\funfun\quad.m<BR>On line 74==&gt; = ...</P>
<P>Error in ==&gt; E:\雪华\dispersive\rw2.m<BR>On line 4==&gt;   Er=quad(@rw0,1e-15,pi./4,tol,[],lamd);</P>
<P>Error in ==&gt; E:\雪华\toolbox\matlab\funfun\quad.m<BR>On line 59==&gt; y = feval(f, x, varargin{:});</P>
<P>Error in ==&gt; E:\雪华\dispersive\E.m<BR>On line 7==&gt;   I=quad(@rw2,0.545,0.555);<BR><BR>各位大侠错在哪里请指点<BR></P>

happy 发表于 2006-3-16 10:09

回复:(yexuehua)[求助]本人新手,关于数值积分的问题...

没太仔细看,不过程序rw0中,n2和cet2两个变量的为数是不一致的<BR><BR>n2 是1*6<BR>cet是1*2<BR><BR>仔细检查一下变量传递吧

yexuehua 发表于 2006-3-16 10:56

<P>各位高手小弟实在无能为力了,请再帮忙解决解决吧</P>

kevinhcj 发表于 2006-3-16 12:59

仔细检查各个变量的size。问题已经很清楚了,是matrix size 的问题。

yexuehua 发表于 2006-3-16 13:42

是matrix dimension不对,问题解决,多谢各位大虾指点,这是个好网站!
页: [1]
查看完整版本: [求助]本人新手,关于数值积分的问题,急!希望得到各位大侠帮助