plotting a plane in three dimensions including data points

443 ビュー (過去 30 日間)
cgo
cgo 2017 年 12 月 7 日
回答済み: Adam Danz 2024 年 10 月 4 日
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?

採用された回答

Erivelton Gualter
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:

その他の回答 (2 件)

cui,xingxing
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

Adam Danz
Adam Danz 2024 年 10 月 4 日
Starting in R2024b, use the constantplane function to plot a 2D plane in 3D axes.
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)
cp =
ConstantPlane with properties: NormalVector: [2 3 -1] Offset: -4 FaceColor: [0.4902 0.4902 0.4902] FaceAlpha: 0.3000 Use GET to show all properties
grid on
xlim([-10 10])
ylim([-10 10])
zlim([-60 60])

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by