运行显示好多Nan inf
总程序如下global kkstructBeams
kkstructBeams=struct('Amplitude',0,'WaveLength',0,'Direction',,'Velocity',0 ...
,'InitialPosition',,'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 = ;
%kkstructBeams(icnt).Direction = kkstructBeams(icnt).Direction/norm(kkstructBeams(icnt).Direction);
kkstructBeams(icnt).Velocity = abInputBeams(icnt,6);
kkstructBeams(icnt).InitialPosition = ;
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
=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 编辑 ] kkstructBeams(icnt).WaveLength=0, 一个数除以零!!
回复 沙发 ChaChing 的帖子
不是的,我后面已经对kkstructBeams(icnt).WaveLength用txt文档进行了赋值啊,已经不在是0了。回复 板凳 wjlwzl 的帖子
interferenceBeamsFromM.txt及abBeamsFromMC.txt是data file吗?资料不给齐, 那知道LZ喂什麽?
回复 地板 ChaChing 的帖子
我把这两个文件传上来,麻烦你再帮我看看,多谢,多谢![ 本帖最后由 wjlwzl 于 2009-3-26 20:03 编辑 ] interferenceBeamsFromM.txt里头的资料就是零!
if interferenceBeamsFromM回圈根本没执行, abBeamsFromMC.txt的资料根本未读入!
kkstructBeams(icnt).WaveLength=0, 一个数除以零!!
页:
[1]