马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
总程序如下
global kkstructBeams
kkstructBeams=struct('Amplitude',0,'WaveLength',0,'Direction',[0 0 0],'Velocity',0 ...
,'InitialPosition',[0 0 0],'Frequency',0,'TimePeriod',0);
interferenceBeamsFromM = 0;
if ~isempty(dir('interferenceBeamsFromM.txt'))
interferenceBeamsFromM = load('interferenceBeamsFromM.txt');
end
if interferenceBeamsFromM % beams from input file
abInputBeams = load('abBeamsFromMC.txt');
iWaveNumber = length(abInputBeams(:,1)); % iWaveNumber must be larger than 1
for icnt=1:iWaveNumber%描述一束光,
kkstructBeams(icnt).Amplitude = abInputBeams(icnt,1);
kkstructBeams(icnt).WaveLength = abInputBeams(icnt,2);
kkstructBeams(icnt).Direction = [abInputBeams(icnt,3) abInputBeams(icnt,4) abInputBeams(icnt,5)];
%kkstructBeams(icnt).Direction = kkstructBeams(icnt).Direction/norm(kkstructBeams(icnt).Direction);
kkstructBeams(icnt).Velocity = abInputBeams(icnt,6);
kkstructBeams(icnt).InitialPosition = [abInputBeams(icnt,7) abInputBeams(icnt,8) abInputBeams(icnt,9)];
kkstructBeams(icnt).Frequency = abInputBeams(icnt,10);
kkstructBeams(icnt).TimePeriod = abInputBeams(icnt,11);
kkstructBeams(icnt).dFrequency = abInputBeams(icnt,12);
kkstructBeams(icnt).deltaFrequency = abInputBeams(icnt,13);
end
end
[x,y]=meshgrid(-100:0.2:100,-100:0.2:100);
icnt=1;d=5;
I=sin(2*pi*sqrt((x-kkstructBeams(icnt).Direction(1,1))^2+(y-kkstructBeams(icnt).Direction(1,2))^2+d^2)/kkstructBeams(icnt).WaveLength)
+sin(2*pi*sqrt((x-kkstructBeams(icnt+1).Direction(1,1))^2+(y-kkstructBeams(icnt+1).Direction(1,2))^2+d^2)/kkstructBeams(icnt+1).WaveLength);
surf(x,y,I);
在I=sin(2*pi*sqrt((x-kkstructBeams(icnt).Direction(1,1))^2+(y-kkstructBeams(icnt).Direction(1,2))^2+d^2)/kkstructBeams(icnt).WaveLength)
+sin(2*pi*sqrt((x-kkstructBeams(icnt+1).Direction(1,1))^2+(y-kkstructBeams(icnt+1).Direction(1,2))^2+d^2)/kkstructBeams(icnt+1).WaveLength);出错,
运行的时候command window 里面显示好多Nan inf 之类该怎么消除。
谢谢啊
我是想做两束光的干涉。
[ 本帖最后由 ChaChing 于 2009-3-26 22:05 编辑 ] |