在 Matlab 中的线条内绘制数据标签

Plotting data labels within lines in Matlab

我的问题类似于post:matlab curve with label

我有一些数据(使用太长的函数获取,无法在此处显示),这给了我 2 个数组:Nv4 (337x1) 和 t (337x1),我想绘制 'a=40' 剧情线上。 我应该可以使用轮廓标签,但我需要先将我的数据转换为矩阵格式。上面的post给出了一个link来解释如何转换我们的数据,不幸的是link已经过期了,我不知道我应该如何转换我的数据。一个例子会很有用!

我 post 将此作为一个新问题提出,因为我没有足够的声誉 post 发表评论

我想还有另一种方法,只需使用 text。这是一个示例:

% Create a sample curve
x = 1:337;
y = sqrt(x);
plot(x,y);

% Define position to display the text
i = round(numel(x)/2);

% Get the local slope
d = (y(i+1)-y(i))/(x(i+1)-x(i));
X = diff(get(gca, 'xlim'));
Y = diff(get(gca, 'ylim'));
p = pbaspect;
a = atan(d*p(2)*X/p(1)/Y)*180/pi;

% Display the text
text(x(i), y(i), 'a=40', 'BackgroundColor', 'w', 'rotation', a);

结果如下:

最佳,