How to change the color of a plane

조회 수: 20 (최근 30일)
James Wallace
James Wallace 2019년 10월 19일
답변: Star Strider 2019년 10월 19일
This is extra credit on our homework. Our instructor wants us to recreate our original plot and add a magenta plane corresponding to the XY plane (Z=0) and plot our points evaluated in the function. I was able to get everything done, except for changing the color of the plane. I have searched on here but I can't seem to find the right wording to get the help I need. Here is the code I have:
figure(4)
mesh(X,Y,Z)
xlabel('x')
ylabel('y')
zlabel('z')
title('MAE 284, Homework 4, Problem 4, Part f')
v = axis;
axis([-2 4 -6 6 -2 2])
hold on
mesh(X,Y,Z0)
for i = 1:length(X_xc) % for loop to plot points
for j = 1:length(Y_xc)
plot3(X_xc(i),Y_xc(j),f(X_xc(i),Y_xc(j)),'*r')
end
end
legend('Function','XY Plane @ Z=0','Evaluated Points','Location','best')
hold off
*mesh(X,Y,Z0) is the plane that I am trying to get the correct color for

답변 (1개)

Star Strider
Star Strider 2019년 10월 19일
How would you define ‘Z0’ as a matrix the size of ‘X’ (or Y’) that is uniformly zero?
(We only give hints to homework problems here.)
See the documentation on surf or mesh to understand how to change the color of the surface faces.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by