Can't Join Points on a Graph
조회 수: 4 (최근 30일)
이전 댓글 표시
For some reason the points in the graph I am drawing don't join up, and I have no idea why. I'm sure it is probably something simple, but I don't have a clue. Can anybody see why?
Thanks, Chris.
if true
clc;
clear all;
% Slit Width;
d = linspace(-10e-6,10e-6,500);
% Distance From Slit to Screen;
z = 0.2;
% Wavelength;
lambda = 500e-9;
% Screen;
s = linspace(-0.02,0.02,500);
% Wave Number;
k = (2.*pi)/lambda;
% Wave Number;
k = (2.*pi)/lambda;
% Width of slit;
w = (2e-6);
% Setting Value of I0
I0 = 5
for xs = linspace(-0.02,0.02,500);
xa = linspace(-10e-6,10e-6,500);
% Path Length;
r = ((((xs-xa).^2)+z.^2).^0.5);
% Electric Field;
dE = (4e-8./d).*((exp(1i.*k.*r))/r);
Etot = sum(dE);
% Etot = sum of E;
Itot = Etot.^2;
plot(xs,Itot,'-');
hold on;
end;
end
댓글 수: 0
답변 (1개)
Image Analyst
2013년 1월 4일
First of all, your for loop is not in the form "for startValue : stepValue : endValue" but you probably don't even need the for loop in the first place. Secondly, Etot is a scalar while xs is a 500 element vector, so your plot() doesn't really make sense.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!