MATLAB二维图上指定位置添加文本(字符串)

因我需要在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是文本的坐标

我原图是:

需要从底部到上部一行一行添加数字,使用的程序为:

  1.     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)
                end
                if 10<wenben&&wenben<100
                    text(x,y,txt)
                end
                x=x+1;
            end
            y=y+1;
            x=0.3;
        end

    结果为:

  2.  

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值