登录论坛

查看完整版本 : [求助]帮忙看看程序出了什么问题


sinophile
2008-10-09, 20:13
这是我编的一个程序,本意是theta1变量坐横坐标,R变量做纵坐标,得到一个关于他俩的曲线,运行程序后也能得到曲线,但是不知道怎么回事,纵坐标的值一直都是1,我用的是MATLAB7.0,希望知道的帮我看看怎么回事啊,头都编大了,谢谢了~

程序如下,
>> n0=1;n1=1.2;n2=1.4;n3=1.6;n4=1.8;n5=2;n6=2.2;ng=2.4;
j=8.85*10^-12;c=1;w=4.55*10^-7;theta1=0:pi/100:pi/2;m=eye(2);
h1=w/4;h2=w/6;h3=w/7;h4=w/8;h5=w;h6=w/9;
N=[n1 n2 n3 n4 n5 n6];H=[h1 h2 h3 h4 h5 h6];
for k=1:6;
F1=n0.*sin(theta1);F2=F1./N(k);theta2=asin(F2);
P1=2*pi*N(k)*H(k).*cos(theta2);P2=P1./w;
P3=sqrt(j/c)*N(k).*cos(theta2);
A=cos(P2);B1=-i.*sin(P2);B=B1./P3;C=-i.*P3.*sin(P2);D=cos(P2);
M=[A,B;C,D];
m=[m(1).*M(1)+m(3).*M(2) m(1).*M(3)+m(3).*M(4);m(2).*M(1)+m(4).*M(2) m(2).*M(3)+m(4).*M(4)];
end;
P0=sqrt(j/c)*n0.*cos(theta1);
F4=F1./ng;theta3=asin(F4);
P4=sqrt(j/c)*ng;Pg=P4./cos(theta3);
r1=m(1)+m(3).*Pg;r2=r1.*P0;r3=m(2)+m(4).*Pg;
r4=r2-r3;r5=r2+r3;
r=r4./r5;
r6=conj(r);
R=r.*r6;plot(theta1,R)

sqqssqq
2008-10-16, 22:05
似乎没问题阿

xiezhh
2008-10-16, 22:43
因为你算出的R都接近于1

0.999999925830073
0.999999925861674
0.999999925956489
0.999999926114545
0.999999926335884
0.999999926620567
0.999999926968671
0.999999927380276
0.999999927855480
0.999999928394380
0.999999928997077
0.999999929663665
0.999999930394232
0.999999931188851
0.999999932047577
0.999999932970436
0.999999933957421
0.999999935008488
0.999999936123544
0.999999937302441
0.999999938544969
0.999999939850849
0.999999941219723
0.999999942651147
0.999999944144585
0.999999945699396
0.999999947314834
0.999999948990038
0.999999950724020
0.999999952515670
0.999999954363738
0.999999956266843
0.999999958223454
0.999999960231900
0.999999962290360
0.999999964396866
0.999999966549302
0.999999968745403
0.999999970982760
0.999999973258825
0.999999975570907
0.999999977916193
0.999999980291744
0.999999982694503
0.999999985121313
0.999999987568921
0.999999990033992
0.999999992513119
0.999999995002838
0.999999997499644
1.000000000000000

五木
2008-10-17, 18:01
学习!!!