MATLAB: How can add texture to the axes?

hgtransformtexture

i made a car and i try to make it move on a race track. i made a plane surface and i add a race track to it as a texture but when i run the m-file; the car run in a separate plane other than the one that has the race track texture!!
Here is my M-File:
———————–
clc;clear all; close all;
I=imread('road.jpg');
[X, Y] = meshgrid(-200:200, -200:200);Z=zeros(size(X));
ground=surf(X,Y,Z, I, ...
'edgecolor', 'none','FaceColor','texturemap');
myaxes=axes('xlim', [-200,200], 'ylim', [-200,200]);
%imagesc([-200,200],[-200,200],I);
grid on; axis equal;
hold on; xlabel('x'); ylabel('y');zlabel('z');
[xcy,ycy,zcy]=cylinder([1,1],20);
h(1)=surface(zcy,ycy,xcy, 'facecolor','yellow');
h(2)=surface(zcy-4,ycy,xcy);%H(1)=surface(zcy,ycy-4,xcy);H(2)=surface(zcy-4,ycy-4,xcy);
combinedobject1=hgtransform('parent',myaxes);combinedobject2=hgtransform('parent',myaxes);
ground=hgtransform('parent',myaxes);
set(h,'parent',combinedobject1); H=copyobj(h,combinedobject2);
Txy = makehgtform('translate',[0 -4 0]);
set(combinedobject2,'Matrix',Txy);
drawnow
xtranslation=1:10; %ytranslation=
bearing=[0:20:5*360];
for i=1:length(bearing)
translation=makehgtform('translate',[0 i 0]);
rotation1=makehgtform('xrotate',(pi/180)*(bearing(i)));
set(combinedobject1,'matrix',translation*rotation1);
rotation2=makehgtform('xrotate',(pi/180)*(bearing(i)));
set(combinedobject2,'matrix',Txy*translation*rotation1);
pause(.2)
end
Please i really need help thanks in advance

Best Answer

Your call
myaxes=axes('xlim', [-200,200], 'ylim', [-200,200]);
creates a new axes with default position, and does so after your call
ground=surf(X,Y,Z, I, ...
'edgecolor', 'none','FaceColor','texturemap');
implicitly created an axes to put the surf() in. If you want the two to be in the same axes, create the axes first and use it as the Parent for the surf
myaxes=axes('xlim', [-200,200], 'ylim', [-200,200]);
ground=surf(X,Y,Z, I, ...
'edgecolor', 'none','FaceColor','texturemap', 'Parent', myaxes);