Communication between MATLAB code and GUI
显示 更早的评论
Hello all,
Maybe I have very simple question, but I can't find out how to start communicate my programme in MATLAB with GUI. GUI looks like this. I placed the background image of the crossroad in GUI, where the whole simulation should run
function background_CreateFcn(hObject, eventdata, handles)
bg = imread('C:\Users\Miroslav\Desktop\Crossroad\cross_matl.png'); imagesc(bg);
uistack(bg, 'bottom');

At the beginning of the matlab program, I initialize the images of cars which has to be moved on the crossroad in GUI.
openfig('C:\Users\Miroslav\Desktop\Crossroad\GUI_final.fig'); %opening GUI
hold on
%----------------------DOWN -> UP --------------------------------------
car_9=imread('C:\Users\Miroslav\Desktop\Crossroad\blue_car.png');
car_10=imread('C:\Users\Miroslav\Desktop\Crossroad\red_car.png');
car_11=imread('C:\Users\Miroslav\Desktop\Crossroad\white_car.png');
car_12=imread('C:\Users\Miroslav\Desktop\Crossroad\yellow_car.png');
CAR_9 = Move_DU(); %deklaration objects to the class
CAR_10 = Move_DU();
CAR_11 = Move_DU();
CAR_12 = Move_DU();
DU = [CAR_9,CAR_10,CAR_11,CAR_12];
car_9_img = imagesc('CData',car_9,'XData',DU(1).getCurrentX(),'YData',DU(1).getCurrentY()); %loading images GUI
car_10_img = imagesc('CData',car_10,'XData',DU(2).getCurrentX(),'YData',DU(2).getCurrentY());
car_11_img = imagesc('CData',car_11,'XData',DU(3).getCurrentX(),'YData',DU(3).getCurrentY());
car_12_img = imagesc('CData',car_12,'XData',DU(4).getCurrentX(),'YData',DU(4).getCurrentY());
du = [car_9_img,car_10_img,car_11_img,car_12_img];
But when I start the program, images of cars makes their own figure, where they start moving

So.. My question is. How to plot images of cars on the background in the GUI?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!