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

5 次查看(过去 30 天)
How do i pull that off using functions??

回答(1 个)

Sean de Wolski
Sean de Wolski 2013-10-1
编辑:Sean de Wolski 2013-10-1
bgc = [0.85 0.85 0.85]; %backgroundcolor
figure('color',bgc);
axes('color',bgc,'XColor',bgc,'YColor',bgc,'ZColor',bgc);
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
  2 个评论
Lewis McKee
Lewis McKee 2017-11-27
The problem I am having with this code is with the mesh.
With the mesh coding, theres constantly an error on line 71:
Undefined function 'surfchk' for input arguments of type 'double'. Error in mesh (line 71) error(surfchk(regdata{:}));
followed by line 13 in this code:
Error in tenniscourt (line 13) mesh([xx,yy,zz],squeeze(ones(size(yy))),'FaceAlpha',0); %net
I'm uncertain on how to fix this. Could someone help?
Adam
Adam 2017-11-27
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by