如何在特定(x,y)
坐标处设置起始情节线?
我下面的代码在图像中读取,显示此图像并逐渐绘制此图像顶部从起始位置到结束位置的一条线。但是,我希望值从特定位置开始,而不是从原点开始。
img = imread('sd.jpg');
image(img);
hold on
h = plot(NaN,NaN);
hold on
for ii = 1:15
pause(0.05)
set(h, 'XData', x(1:ii), 'YData', y(1:ii));
end
答案 0 :(得分:2)
您只需为x
和y
数组中的每个坐标添加偏移量:
img = imread('sd.jpg');
image(img);
hold on
h = plot(NaN,NaN);
hold on;
%// Define x and y offsets here
xoffset = ...;
yoffset = ...;
for ii = 1:15
pause(0.05)
set(h, 'XData', x(1:ii) + xoffset, 'YData', y(1:ii) + yoffset); %// Change
end