Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Issues with imaginary exponentiation for large, widely spaced vectors
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to figure out why using exp(i*x) where x is some vector created by linspace is producing different results depending on how many points I have in x.
Here is some example code for what is happening
x = linspace(-.05,.05,50000);
x2 = linspace(-.05,.05,5000);
test1 = exp((-1i*2*pi/2.04e-6*(0-x).^2)/(2*.5));
test2 = exp((-1i*2*pi/2.04e-6*(0-x2).^2)/(2*.5));
plot(x,unwrap(angle(test1)),x2,unwrap(angle(test2)))
The unwrapped phase plots show a clear quadratic phase for the grid that has 50000 points, but the grid with 5000 points has sharp points in it.
It is not merely something with the unwrap/angle functions. For the application I am trying to do (propagating a beam using the Kirchoff Diffraction Integral) it is producing spurious results (see code below). The plotted result is different depending on n = 10000 or n = 3000
n = 3000;
x = linspace(-.05,.05,n); % result changes for 10000 vs 3000
l = 2.04e-6; % wavelength
k = 2*pi/l;
d = .5; % propagation distance
q = 0.4960 + 0.4156i; % gaussian beam parameter
s = exp(-1i*k*x.^2/(2*q));
prop_field = zeros(1,length(x));
for o = 1:length(x)
prop_field(1,o)= trapz(x,s.*exp((-1i*2*pi/l*(x(o)-x).^2)/(2*d)));
end
plot(x,abs(prop_field))
It seems to be something to do with my exp(1i*x^2) functions as shown by the phase code above.
0 件のコメント
回答 (1 件)
Adi Natan
2012 年 8 月 14 日
"A jump tolerance less than π has the same effect as a tolerance of π. For a tolerance less than π, if a jump is greater than the tolerance but less than π, adding ±2π would result in a jump larger than the existing one, so unwrap chooses the current point. If you want to eliminate jumps that are less than π, try using a finer grid in the domain."
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!