- Define the Plane Properly: Ensure the plane is defined correctly. For a plane at z = 0, the p matrix should have the same dimensions as e and be filled with zeros.
- Check Axes Limits: Make sure the axes limits allow the plane to be visible. Sometimes the plane might be outside the current view.
- Adjust Transparency: Use transparency to ensure both the surface and the plane are visible.
Draw a plane on a surface plot
8 views (last 30 days)
Show older comments
Everything I try to do to draw a plane on a surface plot just keeps failing miserably. I just want to show the intersection! Can anyone help please?
I already have the surface plot coded: surfc(x,z,e);
x,z,e are all 21 x 17 matrix.
So I just tried doing this at the end:
for i = 1:length(x)
for j = 1:min(size(z))
p(i,j) = 0;
end
end
and the plots looked like this:
figure(15)
surfc(x,z,e);
set(gca,'ZScale','log');
hold on
surf(x,z,p);
But I can't see the plane...
I also tried making a mesh and doing it that way but then it said it can't plot negative numbers and so only plotted part of the mesh:
Any help?
0 Comments
Answers (1)
Satwik
on 10 Dec 2024
Hi Paul,
To visualize the intersection of a plane with a surface plot, it is important to ensure that the plane is properly defined and positioned relative to the surface. Here are some steps to achieve this:
Here is a refined version of the code:
% Assuming x, z, e are already defined as 21 x 17 matrices
% Define the plane at z = 0
p = zeros(size(e));
% Plot the surface
figure(15);
surfc(x, z, e);
set(gca, 'ZScale', 'log');
hold on;
% Plot the plane
h = surf(x, z, p);
% Set the plane's color and transparency
set(h, 'FaceAlpha', 0.5, 'EdgeColor', 'none', 'FaceColor', [0 0 1]); % Blue, semi-transparent
% Adjust axes limits if necessary
zlim([-1, max(e(:))]); % Adjust based on your data range
% Add labels for clarity
xlabel('X-axis');
ylabel('Z-axis');
zlabel('E-axis');
title('Surface Plot with Intersection Plane');
% Hold off if you want to stop adding more plots
hold off;
I hope this helps!
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!