How to plot a 3d surf plot?
21 次查看(过去 30 天)
显示 更早的评论
I am executing the following code to plot a 3d surface. I get an error. Can I get some help to correct it. Or if there any altternate plots? For every value of z, I have a data of 26 x 26 which needs to be displayed.
clc; clear all;
% Create a sample 3D matrix of size 26 x 26 x 250
% Replace this with your actual data
data = rand(26, 26, 251);
% Define the x, y, and z coordinates
x = linspace(0, 1.5, 26);
y = linspace(0, 1.5, 26);
z = linspace(0,0.025,251);
% Create meshgrids for the x, y, and z coordinates
[X, Y, Z] = meshgrid(x, y, z);
% Create a figure
figure;
% Create a 3D surface plot
surf(X, Y, Z, squeeze(data));
% Customize plot labels and title
xlabel('X Axis (m)');
ylabel('Y Axis (m)');
zlabel('Z Axis');
title('3D Surface Plot');
% Set viewing angle and axis limits as needed
view(3); % 3D view
axis tight; % Tighten the axis limits
colorbar; % Add a color bar
0 个评论
回答(1 个)
Walter Roberson
2023-8-13
You do not have 3D surface. You have a 26 x 26 x 251 cuboid, and you have a data value for each location in the cuboid. That is not a surface, that is a volume
You can use
volumeViewer(data)
but unfortunately volumeViewer and the underlying volshow do not permit setting the scales or limits of the axes.
3 个评论
Walter Roberson
2023-8-13
I do not understand what it means to "club" a color map ? I also do not understand how you are generating a color map from the 26 x 26 slice ?
Have you looked at slice
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!