Hi Minyoung,
I understand that you want to plot planes in a 3D plot. You can use the “surf” function to plot the planes. Below is an example where I have generated 2 planes and plotted them using the “surf” function.
% Generate sample 2D point data for the planes
x1 = randn(100, 1);
y1 = randn(100, 1);
z1 = zeros(size(x1));
x2 = randn(100, 1);
y2 = randn(100, 1);
z2 = ones(size(x2));
% Fit planes to the 2D point data
plane1 = fit([x1, y1], z1, 'poly11');
plane2 = fit([x2, y2], z2, 'poly11');
% Define the range of x and y values to plot the planes
[X, Y] = meshgrid(linspace(min([x1; x2]), max([x1; x2]), 10), ...
linspace(min([y1; y2]), max([y1; y2]), 10));
% Evaluate the plane equations at each point on the grid
Z1 = plane1(X(:), Y(:));
Z2 = plane2(X(:), Y(:));
% Reshape the Z values to match the grid size
Z1 = reshape(Z1, size(X));
Z2 = reshape(Z2, size(X));
% Plot the planes
figure;
surf(X, Y, Z1, 'FaceAlpha', 0.5);
hold on;
surf(X, Y, Z2, 'FaceAlpha', 0.5);
% Set labels and title
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Plane Fitting with 2D Point Data');
view(3);
axis equal;
Please refer to the following MATLAB documentation page to know more about the “surf” function: