How do you control the end of streamline?
Show older comments
Dear friends,
I am plot electric field line between two circle. I want the electric line end at the outer circle.
I can not find a option to achieve the goal.
Your help would be highly appreciated!
% Define radii of circles
r1 = 5; % radius of inner circle
r2 = 10; % radius of outer circle
% Define charge at center
q = 1; % charge
% Define grid for electric field calculations
x = linspace(-r2,r2,50);
y = linspace(-r2,r2,50);
[X,Y] = meshgrid(x,y);
% Define electric field function
Ex = @(x,y) q/(6.2*pi)*x./(x.^2+y.^2).^1.5;
Ey = @(x,y) q/(6.2*pi)*y./(x.^2+y.^2).^1.5;
% Calculate electric field components on grid
U = Ex(X,Y);
V = Ey(X,Y);
% Plot circles
theta = linspace(0,2*pi,100);
xc1 = r1*cos(theta);
yc1 = r1*sin(theta);
xc2 = r2*cos(theta);
yc2 = r2*sin(theta);
plot(xc1,yc1,'k-',xc2,yc2,'k-')
axis equal
% Plot electric field lines
%quiver(X,Y,U,V,'LineWidth',1,'MaxHeadSize',0.5);
streamline(X,Y,U,V,xc1,yc1)
%streamline(X,Y,U,V,xc2,yc2)
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots 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!
