I don't know what's wrong in this code, it doen't produce a graph.
1 view (last 30 days)
Show older comments
Shahad Alsabi
on 7 Nov 2019
Edited: KALYAN ACHARJYA
on 7 Nov 2019
clear
clc
y = -4:0.01:4;%distance to fringes on the screen
Lembda=input('Enter your wavelength ')
Lambda = Lembda*1e-9; % Wavelength in m
a=input('enter the single slit width ')
a = a*1e-3; % Units to m
d=input('enter the slit width')
d = d*1e-3; % Units to m
L = 5*d;
for i = 1:length(y)
theta(i) = atan(y(i)/100/L); % Unit conversion of y to m %From the figure
alpha(i) = pi.*a.*sin(theta(i))./Lambda;
beta(i) = pi.*d.*sin(theta(i))./Lambda;
IR = (cos(beta(i)).^2).*(sin(alpha(i))./alpha(i)).^2;
end
plot(y,IR)
xlabel('y (in cm)')
ylabel('I/Imax')
title('Intensity Ratio Plot')
grid on
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 7 Nov 2019
Edited: KALYAN ACHARJYA
on 7 Nov 2019
IR(i)= (cos(beta(i)).^2).*(sin(alpha(i))./alpha(i)).^2;
%..^ here inside for loop
0 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!