4d plotting with slices

3 Ansichten (letzte 30 Tage)
Matthew Worker
Matthew Worker am 2 Okt. 2019
Bearbeitet: N/A am 18 Jun. 2021
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 Kommentare
darova
darova am 2 Okt. 2019
But you only have 4 values for Z direction
11Capture.PNG
N/A
N/A am 2 Okt. 2019
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

darova
darova am 2 Okt. 2019
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 Kommentare
N/A
N/A am 8 Okt. 2019
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 am 8 Okt. 2019
What about slice function?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by