# I have plotted two circles and I want to anything outside of the first circle (unit circle) to not be plotted or excluded.

2 views (last 30 days)
Salaheldin Elhadi on 25 Jun 2022
Commented: Salaheldin Elhadi on 25 Jun 2022
So I have four 1D arrays for 2 circles that I plotted. One holds the x values, the other holds the y values for a circle and the other does the same for the other circle. The first circle is a unit circle. The second circle intersects with the unit circle. I want to remove any plotted points of the second circle that are not within the first unit circle.
I used this fx called RMap:
function [c,d] = RMap(a,b)
% A complex function that maps
% R = (z - 1) /(z + 1)
% where
% z = a + jb and R = c + jd
%
% Function inputes: a,b
% Function outputs: c,d
c = (((a.*a)+ (b.*b) - 1) ./ ((a.*a) + (b.*b) + (2.*a) + 1));
d = ((-2.*b) ./ ((a.*a)+(b.*b)+ (2.*a) + 1));
end
And ran this scipt:
np = 100000;
min = -pi*1000;
max = pi*1000;
hold on;
a = 0;
b = 0;
z = a + (1j*b);
e = linspace(z,z,np); %both linspaces are used to create a line that is z=0
f = linspace(min,max,np);
[c,d] = RMap(e,f); %use fx RMap to compute the the line's position into the w-plane
plot(c,d); %plot the result which is a unit circle
axis([-1 1 -1 1]);
hold on;
a = 0;
b = -10;
z = a + (1j*b);
h = linspace(imag(z),imag(z),np); %both linspaces are used to create a line that is z= -j10
g = linspace(min,max,np);
[i,j] = RMap(g,h); %use fx RMap to compute the the line's position into the w-plane
plot(i,j); %plot the result which is a second circle circle
hold off;
Resulting in this figure: I have also attached a copy to this post.
I now want to limit exclude all the points in the samller circle that are outside of the blue unit circle.
I first tried something like
if sqrt((i.*i) + (j.*j)) > 1
%I want to delete those the elements in the array where this condition
%was true, but don't know how to or if there is a better solution.
end

Alan Stevens on 25 Jun 2022
Here's one way:
np = 100000;
min = -pi*1000;
max = pi*1000;
hold on;
a = 0;
b = 0;
z = a + (1j*b);
e = linspace(z,z,np); %both linspaces are used to create a line that is z=0
f = linspace(min,max,np);
[c,d] = RMap(e,f); %use fx RMap to compute the the line's position into the w-plane
plot(c,d); %plot the result which is a unit circle
axis([-1 1 -1 1]);
hold on;
a = 0;
b = -10;
z = a + (1j*b);
h = linspace(imag(z),imag(z),np); %both linspaces are used to create a line that is z= -j10
g = linspace(min,max,np);
[i,j] = RMap(g,h); %use fx RMap to compute the the line's position into the w-plane
[I,J] = find(i.^2+j.^2>1); %*******************
i(I) = nan; j(J) = nan; %*******************
plot(i,j); %plot the result which is a second circle circle
hold off;
function [c,d] = RMap(a,b)
% A complex function that maps
% R = (z - 1) /(z + 1)
% where
% z = a + jb and R = c + jd
%
% Function inputes: a,b
% Function outputs: c,d
c = (((a.*a)+ (b.*b) - 1) ./ ((a.*a) + (b.*b) + (2.*a) + 1));
d = ((-2.*b) ./ ((a.*a)+(b.*b)+ (2.*a) + 1));
end
Salaheldin Elhadi on 25 Jun 2022
Thanks! Helped me out a lot!

R2022a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by