plotting comlex numbers,use one plot command, and each point should be different color

4 views (last 30 days)
z = [complex(2,5),complex(1/5,3/5),(2+i)^3,(1+i)*(1-3*i),complex(5,-12),complex(-3,0),complex(0,2),complex(1,2*sqrt(2)),complex(-0.59,-0.81),complex(5.9,9.15),complex(sqrt(2),sqrt(2)),complex(-3.07,6.72)]
hold on;
grid on;
C = ['y';'m';'c';'r';'g';'b';'w';'r'];
for x = 1:8
plot(z(x),C(x))
end
xlabel("real part");
ylabel("imaginary part");
axis equal;
this is giving me a blank graph with grids. Somone please help.

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 20 Jan 2020
Edited: KALYAN ACHARJYA on 20 Jan 2020
z =[complex(2,5),complex(1/5,3/5),(2+i)^3,(1+i)*(1-3*i),complex(5,-12),complex(-3,0),complex(0,2),complex(1,2*sqrt(2)),complex(-0.59,-0.81),complex(5.9,9.15),complex(sqrt(2),sqrt(2)),complex(-3.07,6.72)];
C=['y';'m';'c';'r';'g';'b';'w';'r';'y';'m';'c';'r'];
for x=1:length(z)
scatter(real(z(x)),imag(z(x)),C(x),'filled');
hold on;
end
grid on;
xlabel("real part");
ylabel("imaginary part");
axis equal;
OR You can avoid the for loop also
z =[complex(2,5),complex(1/5,3/5),(2+i)^3,(1+i)*(1-3*i),complex(5,-12),complex(-3,0),complex(0,2),complex(1,2*sqrt(2)),complex(-0.59,-0.81),complex(5.9,9.15),complex(sqrt(2),sqrt(2)),complex(-3.07,6.72)];
real_z=real(z);
imag_z=imag(z);
%% Now plot real_z & imag_z with scatter plot (multi color)
% See FAQ
grid on;
xlabel("real part");
ylabel("imaginary part");
axis equal;

Community Treasure Hunt

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

Start Hunting!