MATLAB Answers

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

11 ビュー (過去 30 日間)
Kevin Junior
Kevin Junior 2013 年 10 月 1 日
コメント済み: Adam 2017 年 11 月 27 日
How do i pull that off using functions??

  0 件のコメント

サインイン to comment.

回答 (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.

サインイン to comment.

サインイン してこの質問に回答します。


Translated by