前言
基本操作
1. matlab中如何使用类似字典的方式进行键值操作;
ids = [0 1 2 3 4 5 6];
names = {'Unknown', 'Round', 'Left', 'Right', 'Uturn', 'Bicycle', 'Pedestrain'};
sgnm = containers.Map(ids,names);
sgnm(0)
2. 已知x轴的坐标范围和射线斜率,画面中显示射线的说明;
固定y轴坐标y0,根据斜率求解x轴坐标x0,在数据点(x0,y0)添加文本;
y0 = 100;
x0 = 100/kk;
text(x0, y0, sprintf('TFL CONF is %d\nDET TFL SGN is %s', conf, sgnm(sgndir)), 'Color', 'r'); hold on;
3. 如何控制网格的大小尺寸
grid on
grid minor % 切换改变次网格线的可见性。次网格线出现在刻度线之间。并非所有类型的图都支持次网格线。
如何按照自己的想法控制网格大小呢???
4. MATLAB如何通过方向角画线
xx = -lateral:lateral;
kl = tan(0.5*pi+fov/2/180*pi);
yl = kl * xx;
plot(xx, yl, '--m'); hold on;
根据直线的斜率和坐标轴范围画线
5. matlab定义循环变量
for j=1:1:dtfln
k = floor((j+1)/2);
dtflinfo = eval(['can.TrfficLght.TrfficLght',num2str(j)]); % timeseries对象
dtflconf = eval(['dtflinfo.Vis_TFL_Message',num2str(k), '__Vis_TrfficLght', num2str(j), '_Conf']);
dtflsgndir = eval(['dtflinfo.Vis_TFL_Message',num2str(k), '__Vis_TrfficLght', num2str(j), '_SgnDir']);
dtflsts = eval(['dtflinfo.Vis_TFL_Message',num2str(k), '__Vis_TrfficLght', num2str(j), '_sts']);
dtflx = eval(['dtflinfo.Vis_TFL_Message',num2str(k), '__Vis_TrfficLght', num2str(j), '_x']);
conf = dtflconf.Data(i);
sgnfir = dtflsgndir.Data(i);
sts = dtflsts.Data(i);
x = dtflx.Data(i);
kk = tan(0.5*pi - (x-0.5*imgw)/imgw*fov*pi/180);
xx = -lateral:lateral;
yy = k * xx;
plot(xx, yy, 'b*'); hold on;
end
使用两位表示数字,比如01,02,10等;
tflx = eval(['can.TrafficLightX_',sprintf('%02s', num2str(j))]);
6.
参考
1. containers.Map;
2. 控制网格的大小尺寸;
3. MATLAB如何通过方向角画线;
4. matlab定义循环变量;
5. timeseries;
完
标签:TFL,编程,Vis,xx,num2str,matlab,eval,操作,TrfficLght From: https://blog.51cto.com/u_15711436/5927482