Asked by Emmanouil Barmpounakis
on 26 Jan 2017

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?

Answer by Walter Roberson
on 26 Jan 2017

Accepted Answer

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

Emmanouil Barmpounakis
on 27 Jan 2017

Thank you for your answer! I used some other functions, but your answer helped me find them. :)

This is what I used.

scatHand = scatter3(xx, yy, zz); set(scatHand, 'CData', cc);

Dennis_Pana
on 14 Jun 2018 at 13:27

Walter Roberson
on 15 Jun 2018 at 4:01

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) );

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.