3D plot with multiple files

조회 수: 1 (최근 30일)
Darpan Verma
Darpan Verma 2019년 2월 15일
편집: Cris LaPierre 2019년 2월 16일
Hi, I have series of data in 41 simlar group of matrix size [1x88] [41x1] [41x88].
Here 41 similar groups means the points on X axis and matrix [41x1] means the points on the Y axis.
matrix [1x88] [41x88] is the data to be plotted.
I want to know how can I plot this data in 3D? where X axis and Y are positions.

채택된 답변

Cris LaPierre
Cris LaPierre 2019년 2월 16일
편집: Cris LaPierre 2019년 2월 16일
There's some punctuation issues making it difficult to understand the description of your data. Here's what I understand:
  • X-values are contained in the matrix with dimensions [41x1]
  • Y-values are contained in the matrix with dimensions [1x88]
  • Z-values are contained in the matris with dimensions [41x88]
Still unsure how the multiple files factors in. However, yes, if you have those matrices as I described, you can plot in 3D. Now it just depends on what type of plot you want to create. Did you want a line plot? Scatter plot? Mesh? Surface? Plots are handled differently than surfaces. Meshes/surfaces are perfect for your data. With plots, you have to use meshgrid first. Just note that y values to meshgrid are rows of a matrix. Think of if you placed a 2D matrix directly on an X-Y axes.
Here's an example
x = linspace(0,2*pi,41)'; % 41x1
y = linspace(0,pi,88); % 1x88
z = sin(x).^2 * cos(y).^2; % 41x88
figure
surf(x,y,z')
xlabel('X')
ylabel('Y')
zlabel('Z')
figure
[Y,X] = meshgrid(y,x); % Make X and Y 41x88 as well
scatter3(X(:),Y(:),z(:)) % Use linear indexing to turn X, Y, and z into vectors.
xlabel('X')
ylabel('Y')
zlabel('Z')
Surface:
Scatter:

추가 답변 (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