How can I plot in complex plane ?

3 views (last 30 days)
Sewar Alshibly
Sewar Alshibly on 22 Nov 2015
Answered: Ayush on 4 Dec 2024
How can I plot (modulus of z)^2 = 5 + 2*Re(z), in complex plane ?

Answers (1)

Ayush
Ayush on 4 Dec 2024
Hi,
You can create a grid of complex number using “meshgrid” for both the real and imaginary parts. Then compute the modulus squared and the real part of each complex number on the grid. You can use the “contour” function to plot the contour where the equation evaluates to zero. Refer to an example code below for a better understanding:
% Define a range for the real and imaginary parts
realRange = -5:0.1:5;
imagRange = -5:0.1:5;
% Create a grid of complex numbers
[Re, Im] = meshgrid(realRange, imagRange);
Z = Re + 1i * Im;
% Calculate the modulus squared and real part
modulusSquared = abs(Z).^2;
realPart = real(Z);
% Evaluate the original equation
equation = modulusSquared - (5 + 2 * realPart);
% Plot the contour where the equation is zero
figure;
contour(Re, Im, equation, [0 0], 'b-', 'LineWidth', 2);
hold on;
axis equal;
grid on;
xlabel('Re(z)');
ylabel('Im(z)');
title('Plot of |z|^2 = 5 + 2Re(z) in the Complex Plane');
For more information on “contour” plot refer to the below documentation:

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!