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:
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!