How to shade a region between two curves in a complex plane?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Avishek Mukherjee
am 1 Nov. 2021
Kommentiert: Avishek Mukherjee
am 1 Nov. 2021
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 Kommentare
Akzeptierte Antwort
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
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
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')
Weitere Antworten (0)
Siehe auch
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!