How to shade a region between two curves in a complex plane?
2 次查看(过去 30 天)
显示 更早的评论
Here is the problem:
Suppose I have an two circles in the complex plane with inner radius 1 and outer radius 2. I need to shade the region inbetween the circles. I tried the "fill" option, but it's not giving the shading I want. Any help with this would be extremely helpful. Thanks in advance.
Matlab code:
r1 = 2; % Outer radius of the annulus
r2 = 1; % Inner radius of the annulus
for t = 0:0.001:2*pi % Covering all the values of theta
x_int_inner(1,n) = r1*cos(t); % x-value for each coordinate on the annulus
y_int_inner(1,n) = r1*sin(t); % y-value for each coordinate on the annulus
x_int_outer(1,n) = r2*cos(t);
y_int_outer(1,n) = r2*sin(t);
end
plot(x_int_inner+1i*y_int_inner,'g')
hold on
plot(x_int_outer+1i*y_int_outer,'r')
curve1 = x_int_outer+1i*y_int_outer;
curve2 = x_int_inner+1i*y_int_inner;
x2 = [0:0.001:2*pi, fliplr(0:0.001:2*pi)];
inBetween1 = [real(curve1), fliplr(real(curve2))];
inBetween2 = [imag(curve1), fliplr(imag(curve2))];
fill(x2, inBetween1, 'g');
hold on
fill(x2, inBetween2, 'g')
0 个评论
采纳的回答
KSSV
2021-11-1
clc; clear all ;
r1 = 2; % Outer radius of the annulus
r2 = 1; % Inner radius of the annulus
n=0;
t = 0:0.001:2*pi % Covering all the values of theta
x_int_inner = r1*cos(t); % x-value for each coordinate on the annulus
y_int_inner = r1*sin(t); % y-value for each coordinate on the annulus
x_int_outer = r2*cos(t);
y_int_outer = r2*sin(t);
plot(x_int_inner+1i*y_int_inner,'g')
hold on
plot(x_int_outer+1i*y_int_outer,'r')
patch([x_int_inner flip(x_int_outer)],[y_int_inner flip(y_int_outer)],'r')
3 个评论
KSSV
2021-11-1
r1 = 2; % Outer radius of the annulus
r2 = 1; % Inner radius of the annulus
n=0;
t = 0:0.001:2*pi ; % Covering all the values of theta
x_int_inner = r1*cos(t); % x-value for each coordinate on the annulus
y_int_inner = r1*sin(t); % y-value for each coordinate on the annulus
x_int_outer = r2*cos(t);
y_int_outer = r2*sin(t);
plot(x_int_inner+1i*y_int_inner,'g')
hold on
plot(x_int_outer+1i*y_int_outer,'r')
patch(x_int_inner,y_int_inner,'r')
patch(x_int_outer,y_int_outer,'w')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!