Matlab在坐标点上按顺序标序号

程序一:

clear
x=[1 3 7 10];
y=[2 4 9 43];
plot(x,y,'r-')
hold on
for i=1:4%用这个循环
    c=num2str(i);
    c=[' ',c];
    text(x(i),y(i),c)
end
axis([0 10 0 50])

程序二:

x=rand(10,1)*10; 
y=rand(10,1)*10; %x,y表示任意10个点的坐标
plot(x,y,'*');
for i=1:10
    text(x(i)+0.01,y(i)+0.01,num2str(i)) ; %加上0.01使标号和点不重合,可以调整
end


你可能感兴趣的:(MATLAB函数知识)