matlab eval函数 将字符…

matlab中 
eval_r()函数的功能就是将括号内的字符串视为语句并运行

比如 
eval_r('y1=sin(2)')   和语句   y1=sin(2)   等价。

下面举一个它的应用例子:

>> stationx1=1.508;stationy1=6.98;stationx2=8.181;stationy2=6.388;
stationx3=14.85;stationy3=4.69;stationx4=19.95;stationy4=0.4729;
stationx5=16.93;stationy5=-3.726;stationx6=9.699;stationy6=-6.122;
stationx7=1.32;stationy7=-6.985;stationx8=-5.525;stationy8=-6.728;
stationx9=-13.66;stationy9=-5.114;stationx10=-19.98;stationy10=0.2971;
stationx11=-14.93;stationy11=4.658;stationx12=-8.066;stationy12=6.406;


for i=1:12
    stationx(i)=eval_r(['stationx' num2str(i)]);
    stationy(i)=eval_r(['stationy' num2str(i)]);
end
>> stationx,stationy

stationx =

  Columns 1 through 10

    1.5080     8.1810   14.8500   19.9500   16.9300     9.6990     1.3200   -5.5250   -13.6600   -19.9800

  Columns 11 through 12

  -14.9300   -8.0660


stationy =

  Columns 1 through 10

    6.9800     6.3880     4.6900     0.4729   -3.7260   -6.1220   -6.9850   -6.7280   -5.1140     0.2971

  Columns 11 through 12

    4.6580     6.4060
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值