I am trying to draw a tennis court with a green court and white lines
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How do i pull that off using functions??
0 Kommentare
Antworten (1)
Sean de Wolski
am 1 Okt. 2013
Bearbeitet: Sean de Wolski
am 1 Okt. 2013
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 Kommentare
Lewis McKee
am 27 Nov. 2017
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
am 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.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!