I am trying to draw a tennis court with a green court and white lines

6 views (last 30 days)
Kevin Junior
Kevin Junior on 1 Oct 2013
Commented: Adam on 27 Nov 2017
How do i pull that off using functions??

Answers (1)

Sean de Wolski
Sean de Wolski on 1 Oct 2013
Edited: Sean de Wolski on 1 Oct 2013
bgc = [0.85 0.85 0.85]; %backgroundcolor
patch('XData',[0 100 100 0],'YData',[0 0 200 200],'FaceColor','g','Edgecolor','w'); %court
axis equal;
box off
axis tight;
line([15 15],[0 200],'color','w','LineWidth',5); %lines
line([85 85],[0 200],'color','w','LineWidth',5);
[xx,yy,zz] = ndgrid(1:100,100,0:5); %build net
hold on
colormap(zeros(2,3)); %black net
mesh(xx,yy,zz,squeeze(ones(size(yy))),'FaceAlpha',0); %net
view(-25,16); %view
Adam on 27 Nov 2017
Well I don't know if it gets rid of the error, but you didn't use the same syntax in your call to mesh. Sean's original answer passes in xx, yy and zz as 3 distinct arguments, you put them all into a single array.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!