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

10 vues (au cours des 30 derniers jours)
Emmanouil Barmpounakis
Emmanouil Barmpounakis le 26 Jan 2017
Commenté : Walter Roberson le 12 Sep 2022
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?

Réponse acceptée

Walter Roberson
Walter Roberson le 26 Jan 2017
scatteredInterpolant or TriScatteredInterp. Then evaluate at a regular grid. Then you can isosurface() or slice()
  13 commentaires
Farid Khazaeli Moghadam
Farid Khazaeli Moghadam le 12 Sep 2022
Works perfectly. Thanks.
Walter Roberson
Walter Roberson le 12 Sep 2022
Note that the UserData part is only there for potential future code extension with customizing datatips; if you are not planning to customize the datatips then you can leave out the 'UserData' part.
Also, the code to get a color from the color map to pass to FaceColor, uses interpolation of the current level compared to the potential range of the levels. If your levels are dense or if you choose the levels non-linearly, then you could end up with two surfaces the same color. The code does not use "next color" each time -- does not use the standard color order

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by