![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/409000/image.jpeg)
Problems plotting and adding legend to certain point in a plot
4 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/409000/image.jpeg)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!