Clear Filters
Clear Filters

Problems plotting and adding legend to certain point in a plot

4 views (last 30 days)
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

Answers (1)

Setsuna Yuuki.
Setsuna Yuuki. on 10 Nov 2020
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:

Tags

Community Treasure Hunt

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

Start Hunting!