因我需要在matlab二维图上指定位置添加数字,以添加数字为例;
wenben=1; %1,创建一个变量,并赋值
str_wenben=num2str(wenben);%2,用num2str将数字转化为字符串
txt =strcat(str_wenben); %3,用strcat把字符串转化为可添加到图表上的文本
text(x,y,txt) %4,用text把txt写到指定位置,x,y是文本的坐标
我原图是:
需要从底部到上部一行一行添加数字,使用的程序为:
-
x=0.3;y=0.5; wenben=0; while y<10 while x<10 wenben=wenben+1; str_wenben=num2str(wenben); txt =strcat(str_wenben); if wenben>=100 text(x-0.1,y,txt) end if 10>=wenben&&wenben>=1 text(x+0.1,y,txt)