plotting a plane in three dimensions including data points
조회 수: 486 (최근 30일)
이전 댓글 표시
Hi,
I have a plane obtained via regression. Let's say this is z = 2x + 3y + 4. I want to plot this plane AND the data points. How do I do this?
댓글 수: 0
채택된 답변
Erivelton Gualter
2018년 10월 22일
Run the following code:
[x y] = meshgrid(-10:1:10);
z = 2.*x + 3.*y + 4;
surf(x,y,z);
To add the data you can add the following lines:
hold on;
plot3(DataX, DataY, DataZ);
You can check the meshgrid and surf function in the following links:
댓글 수: 0
추가 답변 (2개)
cui,xingxing
2022년 8월 25일
편집: cui,xingxing
2024년 4월 27일
repeated question.
-------------------------Off-topic interlude, 2024-------------------------------
I am currently looking for a job in the field of CV algorithm development, based in Shenzhen, Guangdong, China,or a remote support position. I would be very grateful if anyone is willing to offer me a job or make a recommendation. My preliminary resume can be found at: https://cuixing158.github.io/about/ . Thank you!
Email: cuixingxing150@gmail.com
댓글 수: 0
Adam Danz
2024년 10월 4일
The ConstantPlane is defined by its normal vector and an offset value.
To plot a plane defined by z=2x+3y+4, first refactor the equation into the form ax+by+cz=d which is 2x+3y-z=-4 which defines the vector normal as [2 3 -1] and the offset as -4.
I also set the axis limits to ensure the plane is within view. Line ConstantLines (xline, yline) and ConstantRegions (xregion, yregion), the ConstantPlane extends infinitely in all dimensions.
cp = constantplane([2 3 -1], -4)
grid on
xlim([-10 10])
ylim([-10 10])
zlim([-60 60])
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!