Plane fit (z=ax+by+c) to 3D point data

조회 수: 19 (최근 30일)
Swati Jain
Swati Jain 2017년 9월 7일
댓글: Hongshun Chen 2019년 4월 24일
Hi,
I have step plot (attached) and I want to fit a plane on the lower terrace of it. Excel file of point cloud is attached as well. Data represent in file is N-by-3 numeric data and each column corresponds to x, y and z. Could anyone please help me out how to fit the plane to the lower terrace?

채택된 답변

Akira Agata
Akira Agata 2017년 9월 7일
Assuming that your data is N-by-3 numeric array, say yourData, and each column corresponds to x, y and z, the following code can generate a, b and c for fitting plane (z = ax + by + c).
% Assuming that yourData is N-by-3 numeric array
B = [ones(N,1), yourData(:,1:2)] \ yourData(:,3);
Where a = B(2), b = B(3) and c = B(1).
  댓글 수: 1
Hongshun Chen
Hongshun Chen 2019년 4월 24일
What if the plane is parallel to the z. Singularity will come out when calculating the plane normal.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2017년 9월 7일
[num,txt,raw] = xlsread('Step_scan01_ex.xls') ;
x = num(:,1) ; y = num(:,3) ; z = num(:,3) ;
x0 = min(x) ; x1 = max(x) ; nx = 500 ;
y0 = min(y) ; y1 = max(y) ; ny = 500 ;
xx = linspace(x0,x1,nx) ;
yy = linspace(y0,y1,ny) ;
[X,Y] = meshgrid(xx,yy) ;
Z = griddata(x,y,z,X,Y) ;
surf(X,Y,Z)
shading interp

카테고리

Help CenterFile Exchange에서 Get Started with Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by