Can u find the error in this code
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammed Magdy Sharara
am 20 Nov. 2017
Beantwortet: Star Strider
am 20 Nov. 2017
if true
a=1/500; %width of each slit%
d=1/500;%separation between slits %
N=4; % It is the number of slits%
lims = pi/4;
theta = linspace(-lims, lims, 501);
lambda0=0.000049; % It is the wavelength of the green light%
n=1; %It represents the medium%
lambda=lambda0/n;
Y=0;
k=2*pi/lambda;
alpha=0.5*k*d*sin(theta);
L=1;
I=((sin(N*alpha))/(N*sin(alpha)))^2;
%plot% clf; plot(theta,I) end
Am trying to draw the interference of green light can u find the error in this code
0 Kommentare
Akzeptierte Antwort
Star Strider
am 20 Nov. 2017
Vectorize:
I=((sin(N*alpha))./(N*sin(alpha))).^2;
↑ ↑
HERE AND HERE
Use element-wise operations, .* instead of *, and .^ instead of ^.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!