MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何在Matlab中标记两个向量? (https://www.labfans.com/bbs/showthread.php?t=23117)

poster 2019-12-10 20:30

如何在Matlab中标记两个向量?
 
我有一个2列矩阵(称为M ,使用Matlab的plot命令( plot(M) )可视化为两个向量。我有两个问题:
[LIST=1][*]我想在图上标记矢量本身。[*]我想在绘图上标记矩阵的每一行(即每个矢量分量)。[/LIST]我将如何去做那些事情?



[B]回答:[/B]

一个例子:

M = cumsum(rand(10,2) - 0.5); x = 1:size(M,1); plot(x, M(:,1), 'b.-', x, M(:,2), 'g.-') legend('M1', 'M2') for i=x text(i+0.1, M(i,1), sprintf('%.2f', M(i,1)), 'FontSize',7, 'Color','b'); text(i+0.1, M(i,2), sprintf('%.2f', M(i,2)), 'FontSize',7, 'Color','g'); end [IMG]https://i.stack.imgur.com/hvCLY.png[/IMG]

或者,您可以使用:

datacursormode() 这将使用户能够[URL="http://www.mathworks.com/help/matlab/creating_plots/data-cursor-displaying-data-values-interactively.html"]指向并单击点[/URL]以查看数据标签。



[url=https://stackoverflow.com/questions/2243069]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 10:10

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.