Creating surface plot from 3 coloum Matrix?

8 ビュー (過去 30 日間)
Niklas Federkeil
Niklas Federkeil 2021 年 4 月 7 日
回答済み: Niklas Federkeil 2021 年 4 月 16 日
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.

採用された回答

Niklas Federkeil
Niklas Federkeil 2021 年 4 月 16 日
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by