MATLAB 板


LINE

如果标题下的不好请多包涵 OrZ 大家好~小弟刚开始学用Movie 写了一点code有一些问题如下: 1.在图中要画两台车,若用rectangle画车,程式可以跑但是车子移动过程 其中一台会有残影。请问如何可以消掉残影呢? 2.如果直接读取车子的图片则有一台无法显示,好像跟读取顺序有关。 要怎麽做才能使两台车同时显现呢? 3.动画好像会重复跑两次,而且第二次的座标完全跑掉了。要怎麽做才能只跑一次? 4.应该如何正确uistack呢?我一直出现'Invalid or deleted object.' 错误 问题有点多,还请版上高手解惑~谢谢 以下附上程式码: % Car Information l = 4.91; % vehicle length (Hyundai grandeur specs) [m] l_r = 3; % length rear end - cg [m] l_f = l-l_r; % length front end - cg [m] w = 1.86; % width of vehicle (Hyundai grandeur specs) [m] car_size=[l_r l_f w/2 w/2]; % car size array v1 = 60*1000/3600; % constant speed of car1 = 60 km/h v2 = 65*1000/3600; % constant speed of car2 = 80 km/h % Road Information % 1000m in total distance rl = 1000; % road length rw = 10; % road width % Trajectory Information % [x,y,phi] (left lower corner of the car box) x1 = [0:v1:rl]'; y1 = 2.5-0.5*w*ones(length(x1),1); x2 = [0:v2:rl]'; y2 = 7.5-0.5*w*ones(length(x2),1); phi1 = zeros(length(x1),1); phi2 = zeros(length(x2),1); traj1 = [x1,y1,phi1]; traj2 = [x2,y2,phi2]; leng_traj2 = length(traj2); % Drawing picture frame = 100; for i=1:leng_traj2 % read a car uniquebgcolor = [0 0 0]; % background color car1 = imread('car.png','BackgroundColor',uniquebgcolor); car2 = imread('car2.png','BackgroundColor',uniquebgcolor); % car rotation with yaw angle car1 = imrotate(car1,traj1(i,3),'bilinear','loose'); car2 = imrotate(car2,traj2(i,3),'bilinear','loose'); % mask1 = bsxfun(@eq,car1,reshape(uniquebgcolor,1,1,3)); % mask2 = bsxfun(@eq,car2,reshape(uniquebgcolor,1,1,3)); % display image % rec1=rectangle('position',[traj1(i,1) traj1(i,2) l w],'FaceColor','r'); % rec2=rectangle('position',[traj2(i,1) traj2(i,2) l w],'FaceColor','b'); % set(rec1,'erasemode','non'); % set(rec2,'erasemode','non'); car1_im = image(car1,'Xdata',[traj1(i,1),traj1(i,1)+l],... 'Ydata',[traj1(i,2),traj1(i,2)+w]); car2_im = image(car2,'Xdata',[traj2(i,1),traj2(i,1)+l],... 'Ydata',[traj2(i,2),traj2(i,2)+w]); % drawing road image line([0,rl],[0,0],'LineWidth',2,'Color','k'); line([0,rl],[rw,rw],'LineWidth',2,'Color','k'); line([0,rl],[rw/2,rw/2],'LineWidth',2,'Color','y'); % moving axes axis xy % cartesian convention axis([traj1(i,1)-5 traj1(i,1)+50 traj1(i,2)-10 traj1(i,2)+10]); % keep car image on the top uistack(car1_im,'top'); uistack(car2_im,'top'); % recording each movie frame M(i) = getframe(gcf); % get current frame end movie(M) --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 128.32.164.86
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/MATLAB/M.1399332573.A.403.html







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:iOS站内搜寻

TOP