Creating surface plot from 3 coloum Matrix?

6 visualizaciones (últimos 30 días)
Niklas Federkeil
Niklas Federkeil el 7 de Abr. de 2021
Respondida: Niklas Federkeil el 16 de Abr. de 2021
Good day together,
I would like to know if it is possible to create a surface plot using matlab from a 3 coloum matrix with different X and Y values. To be a bit more clear here is an example of how the data would look:
X Y Z
2000 20 rand
2000 40 rand
2000 60 rand
2500 30 rand
2500 50 rand
2500 70 rand
3000 20 rand
3000 60 rand
I found an answer here: https://de.mathworks.com/matlabcentral/answers/412639-creating-surface-plot-from-a-matrix-with-3-columns but this seems to only work when you always have the same Y values for each X step or at least the same amount of Y for each X value.

Respuesta aceptada

Niklas Federkeil
Niklas Federkeil el 16 de Abr. de 2021
I solved the issue by creating a matrix with all the unique x and y values filling this with the corresponding z value and then filling the empty spaces with NaN. This way I am able to use the contourf for plotting.
from example
2000 2500 3000
20 rand NaN rand
30 NaN rand NaN
40 rand NaN NaN
50 NaN rand NaN
60 rand NaN rand
70 NaN rand NaN

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by