How to plot a 3d surf plot?
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kalasagarreddi Kottakota
am 13 Aug. 2023
Kommentiert: Kalasagarreddi Kottakota
am 13 Aug. 2023
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 Kommentare
Antworten (1)
Walter Roberson
am 13 Aug. 2023
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 Kommentare
Walter Roberson
am 13 Aug. 2023
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
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!