Create a surface between two sets of 3d data points

조회 수: 4 (최근 30일)
Matthew Davenport
Matthew Davenport 2021년 4월 19일
댓글: Clayton Gotberg 2021년 4월 20일
Hi,
I have 2 sets of data points that create lines on a 3-Dimensional plot.
I would like create a linear surface between the two sets of data points. Each data point on one set of data would correspond with the data point on the other set. I am unsure of how to go about this other than finding a linear equation for each coupled data points.
r1 = [-2.2607e-05; 1.1301e-08; 1.4319e-04; -1.4319e-04];
x = linspace(0,1000);
y = x;
u1_3 = (r1(1)*x.^2 + r1(2)*y.^3);
figure(3)
hold on
grid on
scatter3(x,y,u1_3-100,'b')
X2 = linspace(0,0);
Y2 = linspace(0,1000);
Z2 = linspace(0,0);
scatter3(X2,Y2,Z2-100,'k')
zlim([-1e3 0])
ylim([-1000 1000])
xlim([-1000 1000])
xlabel('x (meters)')
ylabel('y (meters)')
zlabel('Deflection, m/V')
hold off
Any help on this is much appreciated!
  댓글 수: 5
Sean de Wolski
Sean de Wolski 2021년 4월 19일
What are you trying to do with this surface? Just visualizing, using it to interpolate?
Matthew Davenport
Matthew Davenport 2021년 4월 19일
I would like to show the normal vectors of the surface. The blue set of data represents an actuartor arm position with a surface conected to the black data set.

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

채택된 답변

Clayton Gotberg
Clayton Gotberg 2021년 4월 19일
편집: Clayton Gotberg 2021년 4월 19일
When you send matrices to the plotting command, the way that it plots depends on the orientation of those matrices
% x, y, z already defined as row matrices (1 x n)
X = [x1; x2]; % Create a matrix with x1(1) above x2(1); do the same for Y and Z
Y = [y1; y2];
Z = [z1; z2];
plot3(X,Y,Z) % Result: n lines with two points (x1,y1,z1) and (x2,y2,z2)
plot3(X',Y',Z') % Result: 2 lines with n points
If you are trying to create a surface, specifically, the surf command should take the exact same inputs and create a single surface.
  댓글 수: 2
Matthew Davenport
Matthew Davenport 2021년 4월 19일
Thank you for your help! I would also like to show the surface normals, however surfnorm returns an error that z must be at lease 3-by-3. Do you have any suggestions?
Clayton Gotberg
Clayton Gotberg 2021년 4월 20일
I would guess that the error is because surfnorm needs more information to calculate the normal vector than is present in a 2 x n array. If you want to include the normals, you will probably need to calculate and plot them yourself instead of using that function. I'm also not certain what normal you're looking for as a line has infinite normals. You'd need to define a plane and then either find the normal vector to that plane or find a line perpendicular to the line of interest in that plane.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by