4d plotting with slices

조회 수: 3 (최근 30일)
Matthew Worker
Matthew Worker 2019년 10월 2일
편집: N/A 2021년 6월 18일
Hello :)
I have 4d data (x y z coordinates and and V). I am hoping to represent the data similar to the slice function approach however I do not want the V values to be inerpolated for each square. I want each square to represent one of my data points (so x = 0, y=0, z=0 is a whole square not the inersection of squares as the slice function does). I could also potentially have a graph with circles for each data point or any other suggestions. I just need every data point to be visible.
[X,Y,Z] = meshgrid(0:4, 0:4, 0:3);
V = [0.95, 1.05, 0.87, 0.9, 0.66;
1.25,1.79, 18.1, 1.18, 1.22;
1.95, 6.27, 37.4, 6, 2.13;
3.06, 3.94, 11.4, 2.4, 1.8;
1.1, 1.3, 3.2, 1.8, 0.8];
V(:, :, 2) = [2.9, 2.7, 1.9, 3.1, 2.1;
1.1, 5.7, 18.5, 7.4, 0.6;
3, 10.9, 37.8, 14.5, 4.2;
2.6, 7.4, 9.4, 6.2, 3.8;
3, 2.2, 5.2, 3.8, 3];
V(:, :, 3) = [1.8, 3.2, 3, 3, 2.2;
3, 3, 14.9, 7.4, 1.8;
3.2, 10.7, 11.5, 23.9, 6.6;
2.2, 7.8, 9.8, 8.6, 3.8;
1.6, 1.8, 3.8, 3.8, 3];
V(:, :, 4) = [1.8, 2, 5, 4.4, 3.8;
2.2, 9.4, 8.8, 17.9, 5.8;
3.4, 20, 26.1, 20.1, 6.2;
4.4, 14.3, 6.6, 13.7, 6.6;
3.8, 3, 7.6, 3.4, 2.6];
zslice = [];
xslice = [0,1,2,3,4];
yslice = [];
figure
slice(X, Y, Z, V,xslice,yslice,zslice);
pbaspect([3 1 1])
colorbar
xlabel('X'); ylabel('Y'); zlabel('Z')
  댓글 수: 2
darova
darova 2019년 10월 2일
But you only have 4 values for Z direction
11Capture.PNG
N/A
N/A 2019년 10월 2일
yes so i want 4 squares one for each value. I want each square to represent one of my data points not each square intersection

댓글을 달려면 로그인하십시오.

채택된 답변

darova
darova 2019년 10월 2일
slice() just doesn't use last column and row for displaying colors
So i just copied values
[X,Y,Z] = meshgrid(0:4, 0:5, 0:4); % create bigger mesh
V = [0.95, 1.05, 0.87, 0.9, 0.66;
%%%%%%%
V = cat(1,V,V(end,:,:)); % one more row (last row copy)
V = cat(3,V,V(:,:,end)); % more data for 3d dimension (last matrix copy)
result:
img1.png
  댓글 수: 2
N/A
N/A 2019년 10월 8일
thank you! am just wondering how would you do z slices instead ? I tried doing this - but doen't work... If you know, would be greatly appreciated :) x
[X,Y,Z] = meshgrid(0:5, 0:5, 0:3);
...
V = cat(1,V,V(end,:,:));
V = cat(1,V,V(:,end,:));
darova
darova 2019년 10월 8일
What about slice function?

댓글을 달려면 로그인하십시오.

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