How to plot 4d data?

2 views (last 30 days)
Devdutt Tripathi
Devdutt Tripathi on 15 Sep 2020
Answered: BOB MATHEW SYJI on 15 Sep 2020
for each (x,y,z) coordinate point there is a unique value I need to plot.So,its like a voulmetric visualisation of data.Take the data below for example.
x [nm] y [nm] z [nm] weight [kg]
--------------------------------------------------------------
-400 1975 -3000 8.06289e+013
-360 1975 -3000 2.23969e+014
-320 1975 -3000 3.67308e+014
-280 1975 -3000 5.10648e+014
-240 1975 -3000 6.53987e+014
-200 1975 -3000 7.44523e+014
-160 1975 -3000 7.91981e+014
-120 1975 -3000 8.39439e+014
-80 1975 -3000 8.86898e+014
-40 1975 -3000 9.34356e+014
0 1975 -3000 9.81814e+014
40 1975 -3000 9.47209e+014
80 1975 -3000 8.99751e+014
120 1975 -3000 8.52293e+014
160 1975 -3000 8.04834e+014
200 1975 -3000 7.57376e+014
240 1975 -3000 6.92808e+014
280 1975 -3000 5.49468e+014
320 1975 -3000 4.06129e+014
360 1975 -3000 2.62789e+014
400 1975 -3000 1.1945e+014
-400 1976 -3000 1.81237e+014
-360 1976 -3000 3.15783e+014
-320 1976 -3000 3.94467e+014
-280 1976 -3000 4.74098e+014
-240 1976 -3000 5.48437e+014
-200 1976 -3000 6.15305e+014
-160 1976 -3000 6.73419e+014
-120 1976 -3000 7.20603e+014
-80 1976 -3000 7.54657e+014
-40 1976 -3000 7.75999e+014
0 1976 -3000 7.84036e+014
40 1976 -3000 7.75999e+014
80 1976 -3000 7.54657e+014
120 1976 -3000 7.20603e+014
160 1976 -3000 6.73419e+014
200 1976 -3000 6.15305e+014
240 1976 -3000 5.48437e+014
280 1976 -3000 4.74099e+014
320 1976 -3000 3.94467e+014
360 1976 -3000 3.15783e+014
400 1976 -3000 1.81237e+014
-400 1977 -3000 1.80061e+014
-360 1977 -3000 3.13735e+014
-320 1977 -3000 3.91908e+014
-280 1977 -3000 4.71023e+014
-240 1977 -3000 5.44879e+014
-200 1977 -3000 6.11313e+014
-160 1977 -3000 6.6905e+014
-120 1977 -3000 7.15928e+014
-80 1977 -3000 7.49762e+014
-40 1977 -3000 7.70965e+014
0 1977 -3000 7.7895e+014
40 1977 -3000 7.70965e+014
80 1977 -3000 7.49762e+014
120 1977 -3000 7.15928e+014
160 1977 -3000 6.6905e+014
200 1977 -3000 6.11313e+014
240 1977 -3000 5.44879e+014
280 1977 -3000 4.71023e+014
320 1977 -3000 3.91908e+014
360 1977 -3000 3.13735e+014
400 1977 -3000 1.80061e+014
-400 1978 -3000 1.78885e+014
-360 1978 -3000 3.11686e+014
-320 1978 -3000 3.89349e+014
-280 1978 -3000 4.67947e+014
-240 1978 -3000 5.41321e+014
-200 1978 -3000 6.07322e+014
-160 1978 -3000 6.64682e+014
-120 1978 -3000 7.11254e+014
-80 1978 -3000 7.44866e+014
-40 1978 -3000 7.65931e+014
0 1978 -3000 7.73864e+014
40 1978 -3000 7.65931e+014
80 1978 -3000 7.44866e+014
120 1978 -3000 7.11254e+014
160 1978 -3000 6.64682e+014
200 1978 -3000 6.07322e+014
240 1978 -3000 5.41321e+014
280 1978 -3000 4.67947e+014
320 1978 -3000 3.89349e+014
360 1978 -3000 3.11686e+014
400 1978 -3000 1.78885e+014
-400 1979 -3000 1.7771e+014
-360 1979 -3000 3.09638e+014
-320 1979 -3000 3.8679e+014
-280 1979 -3000 4.64872e+014
-240 1979 -3000 5.37763e+014
-200 1979 -3000 6.0333e+014
-160 1979 -3000 6.60313e+014
-120 1979 -3000 7.06579e+014
-80 1979 -3000 7.39971e+014
-40 1979 -3000 7.60897e+014
0 1979 -3000 7.68778e+014
40 1979 -3000 7.60897e+014
80 1979 -3000 7.39971e+014
120 1979 -3000 7.06579e+014
160 1979 -3000 6.60313e+014
200 1979 -3000 6.0333e+014
240 1979 -3000 5.37764e+014
280 1979 -3000 4.64872e+014
320 1979 -3000 3.8679e+014
360 1979 -3000 3.09638e+014
400 1979 -3000 1.7771e+014
-400 1980 -3000 1.76534e+014
-360 1980 -3000 3.07589e+014
-320 1980 -3000 3.84231e+014
-280 1980 -3000 4.61796e+014
-240 1980 -3000 5.34206e+014
-200 1980 -3000 5.99339e+014
-160 1980 -3000 6.55945e+014
-120 1980 -3000 7.01904e+014
-80 1980 -3000 7.35075e+014
-40 1980 -3000 7.55863e+014
0 1980 -3000 7.63692e+014
40 1980 -3000 7.55863e+014
80 1980 -3000 7.35075e+014
120 1980 -3000 7.01904e+014
160 1980 -3000 6.55945e+014
200 1980 -3000 5.99339e+014
240 1980 -3000 5.34206e+014
280 1980 -3000 4.61796e+014
320 1980 -3000 3.84231e+014
360 1980 -3000 3.07589e+014
400 1980 -3000 1.76534e+014

Answers (2)

KSSV
KSSV on 15 Sep 2020
Let A be you m*4 data.
x = A(:,1) ; y = A(:,2) ; z = A(:,3) ; c = A(:,4) ;
nx = length(unique(x)) ;
ny = length(unique(y)) ;
X = reshape(x,nx,ny) ;
Y = reshape(y,nx,ny) ;
Z = reshape(z,nx,ny) ;
C = reshape(c,nx,ny) ;
surf(X,Y,Z,C)

BOB MATHEW SYJI
BOB MATHEW SYJI on 15 Sep 2020
Hi, this code visualises the data as scatter plot. Hope this helps.
%dat is your data file
x = dat(:,1);
y = dat(:,2);
z = dat(:,3);
wt = dat(:,4);
scatter3(x,y,z,40,wt,'filled')
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
xlabel('x(nm)')
ylabel('y(nm)')
zlabel('z(nm)')
cb = colorbar;
cb.Label.String = 'Weight(Kg)';

Tags

Community Treasure Hunt

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

Start Hunting!