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

조회 수: 3(최근 30일)
aakaar Jaiswal 20 Jan 2020
편집: KALYAN ACHARJYA 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)]
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;

로그인 to comment.

### 답변(1개)

KALYAN ACHARJYA 20 Jan 2020
편집: KALYAN ACHARJYA 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;

#### 댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

Translated by