## Create 4D surface plot from x, y, z and c column vectors

### Emmanouil Barmpounakis (view profile)

on 26 Jan 2017
Latest activity Commented on by Walter Roberson

on 15 Jun 2018

### Walter Roberson (view profile)

I have 4 columns in a table named A. The 3 columns x,y,z are the initial conditions and c is the result of a specific function I use c = f(x,y,z). I want to show the result c[i] for every case x[i],y[i],z[i] as a surface where the colour will stand for how high/low the value of c is.
I use the code below:
xx = A.x
yy = A.y
zz = A.z
cc = A.c
but the following error appears:
Z must be a matrix, not a scalar or vector.
Any ideas?

### Walter Roberson (view profile)

on 26 Jan 2017

scatteredInterpolant or TriScatteredInterp. Then evaluate at a regular grid. Then you can isosurface() or slice()

Emmanouil Barmpounakis

### Emmanouil Barmpounakis (view profile)

on 27 Jan 2017
This is what I used.
scatHand = scatter3(xx, yy, zz);
set(scatHand, 'CData', cc);
Dennis_Pana

### Dennis_Pana (view profile)

on 14 Jun 2018
i do not understand the answer. Can you please send me your code or more details at least because i have exactly the same issue.
Walter Roberson

### Walter Roberson (view profile)

on 15 Jun 2018
The original question had been about building a 4D surface plot; the technique for that is
xx = A.x;
yy = A.y;
zz = A.z;
cc = A.c;
F = scatteredInterpolant(xx, yy, zz, cc);
Nx = 10; Ny = 10; Nz = 10;
xv = linspace(min(xx),max(xx),Nx);
yv = linspace(min(yy),max(yy),Ny);
zv = linspace(min(zz),max(zz),Nz);
[xq, yq, zq] = ndgrid(xv, yv, zv);
cc_cuboid = F(xq, yq, zq);
Nprobe = 5;
probe_cc = linspace(min(cc), max(cc), Nprobe); %5 isosurfaces
for K = 1 : Nprobe
patch(isosurface(xq, yq, zq, cc_cuboid, probe_cc(K)));
end
legend( sprintf('cc = %g', probe_cc) );