How to assign point name to points in an array and then plot them ?

2 vues (au cours des 30 derniers jours)
Naïm
Naïm le 1 Déc 2022
Modifié(e) : Matt J le 2 Déc 2022
Hi all, I would like to name my points that are inside a matrix. and then plot them.
clc; clear all; close all;
A = [0,1.5+1.5i,4.5i,-6.75+6.75i,-20.25];
plot(A,'o')
I am not english speaker, please use simple terms for answer.
Thank you very much.

Réponse acceptée

Walter Roberson
Walter Roberson le 2 Déc 2022
A = [0,1.5+1.5i,4.5i,-6.75+6.75i,-20.25];
Anames = {'', 'start', 'impulse', 'peak', 'relax'};
Ar = real(A);
Aim = imag(A);
scatter(Ar, Aim, 'ro');
text(Ar, Aim + 0.2, Anames, 'HorizontalAlignment', 'left')

Plus de réponses (2)

Matt J
Matt J le 1 Déc 2022
Modifié(e) : Matt J le 1 Déc 2022
Hi all, I would like to name my points that are inside a matrix.
You could convert the matrix to a table with row names that you would provide, e.g.,
A = [0,1.5+1.5i,4.5i,-6.75+6.75i,-20.25];
names={'Jack','Fred','Emily','Carol','Donald'};
T=array2table(A(:),'Row',names)
T = 5×1 table
Var1 ____________ Jack 0+0i Fred 1.5+1.5i Emily 0+4.5i Carol -6.75+6.75i Donald -20.25+0i
  2 commentaires
Naïm
Naïm le 1 Déc 2022
merci monsieur
Naïm
Naïm le 1 Déc 2022
I think i miswrote my question, I want to plot the points with names

Connectez-vous pour commenter.


Matt J
Matt J le 2 Déc 2022
Modifié(e) : Matt J le 2 Déc 2022
names={'Jack','Fred','Emily','Carol','Donald'};
A = [0,1.5+1.5i,4.5i,-6.75+6.75i,-20.25];
n=numel(A);
H=plot(graph(speye(n),'omitself'),...
'XData',real(A),'YData',imag(A),'NodeLabel',names);

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by