Labeling points of plot()

782 ビュー (過去 30 日間)
naga240
naga240 2023 年 1 月 4 日
回答済み: Cameron 2023 年 1 月 4 日
I have the following code using eigenshuffle.
%% 2a)
a=-2:0.01:6;
A2=zeros(2,2,length(a));
for i=1:length(a)
A2(:,:,i)= ([0 1; -a(1,i) -1]);
end
[V,E]=eigenshuffle(A2)
Unrecognized function or variable 'eigenshuffle'.
E_real=squeeze(real(E))
E_imag=squeeze(imag(E))
hold on
grid on
axis equal
plot(E_real(1,:),E_imag(1,:))
plot(E_real(2,:),E_imag(2,:))
I want to label each point of the data such that when I click on the line i can also see the value of a. Sort of how nyquist works:
Thanks in advance!

採用された回答

Cameron
Cameron 2023 年 1 月 4 日
For a regular plot, you can use the Data Tips icon on the axtoolbar to manually select the points you want to view. To do it programatically, you would need to use the function datatip.
x = 0:20;
y = x.^2;
p = plot(x,y);
datatip(p,x(10),y(10));
or if you want to add custom information, you can use dataTipTextRow
x = 0:20;
y = x.^2;
str = "Value #" + (0:20)';
p = plot(x,y);
row = dataTipTextRow('ID',str);
p.DataTipTemplate.DataTipRows(end+1) = row;
datatip(p,x(10),y(10));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by