How to shade a region between two curves in a complex plane?

2 Ansichten (letzte 30 Tage)
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')

Akzeptierte Antwort

KSSV
KSSV am 1 Nov. 2021
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
t = 1×6284
0 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290
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 Kommentare
KSSV
KSSV am 1 Nov. 2021
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')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line 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!

Translated by