matlab中
stationx(i)=eval_r(['stationx' num2str(i)]);
stationy(i)=eval_r(['stationy' num2str(i)]);
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
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
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
end
>> stationx,stationy
stationx =
stationy =