www.gusucode.com > 红绿灯十字路口模拟源码程序 > 红绿灯十字路口模拟源码程序/Animated_TrafficLightsOOP/start.m
clear,close, X=[14.9,10.3,8.5,17]; Y=[6.5,16.5,8.2,15]; map; % uicontrol('Style', 'pushbutton', 'String', 'flashY','Position', [16 5 2 0.5], 'Callback', 'cla'); set(gcf,'MenuBar','none','Name','Animated traffic lights on road intersection -- OOP demo') lampsAll=tLamps(X,Y); for i=1:2 lampsAll=gray2flash(lampsAll); end for i=1:2 lampsAll=rgb2all(lampsAll); end lampsAll=gray2flash(lampsAll); %% traffic lights are controlled from menu now cont=1 menu1=uimenu(gcf,'Label','Yellow_Flash', 'Callback', 'cont=1'); menu1=uimenu(gcf,'Label','Red_Yellow_Green', 'Callback', 'cont=2'); menu1=uimenu(gcf,'Label','Finish', 'Callback', 'cont=0;'); disp('use menu to change lights or to finish') text(15.2,20,'use menu to change lights') while cont switch cont case 1 %lampsAll=gray2all(lampsAll); lampsAll=gray2flash(lampsAll); case 2 lampsAll=rgb2all(lampsAll); end end close