필터 지우기
필터 지우기

Problems plotting and adding legend to certain point in a plot

조회 수: 4 (최근 30일)
Ryan Davidson
Ryan Davidson 2020년 11월 9일
답변: Setsuna Yuuki. 2020년 11월 10일
Hi,
I have a simple code that plots 7 eigenvalues as follows:
A = load('XV15A_200kts_A9.txt');
Result = eig(A)
plot(Result,'+')
What I would like to do is for pairs of points (ie -2 + 0.5i and -2 - 0.5i) to have a different colour to other points and I would ideally like to label these points in the legend (so in this example i would like the two points to be marked red and in the legend say 'Dutch Roll Mode')
Any help would be appreciated

답변 (1개)

Setsuna Yuuki.
Setsuna Yuuki. 2020년 11월 10일
to place the dots with different colors:
compleja = 0;
A = rand(100);
result = eig(A)
j = 1;
for i = 1:length(result)-1
if(result(i) == conj(result(i+1)))
compleja(j) = result(i);
j = j+1;
end
end
result = result(2:length(result));
resultReal = real(result); resultComplex = imag(result);
scatter(resultReal,resultComplex,'g +','linewidth',2); hold on;
resultReal = real(compleja); resultComplex = imag(compleja);
scatter(resultReal,resultComplex,'r +','linewidth',2)
compleja = conj(compleja);
resultReal = real(compleja); resultComplex = imag(compleja);
scatter(resultReal,resultComplex,'b +','linewidth',2)
xlabel('Real'); ylabel('Imaginario')
legend('Only Real','Red category','Blue category')
A example with 100x100 matrix:

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by