How to plot 3D surface from 2D array?

9 ビュー (過去 30 日間)
Vincent Laroche
Vincent Laroche 2020 年 10 月 5 日
回答済み: Vincent Laroche 2020 年 10 月 6 日
Hi, I'm trying to create a smooth tube surface using streamlines in Matlab's "wind" dataset. The picture below shows what the plot of the streamlines looks like; I want to make a smooth surface that connects them.
The code that I attached is what I wrote to collect the coordinates of all the points along the streamlines into 2D arrays. So now I have three 2D arrays (one for X,Y,Z each) of the same size where each row represents the points in one streamline. Now I want to create a smooth 3D surface where the connectivity of the surface points is defined by the adjacency of points in the 2D arrays. Matlab's surf() and mesh() don't work for this because the Z coordinates aren't a function of X,Y. I'm picturing this in my head as rolling up a piece of paper (the 2D array) into a tube. Does Matlab have a function for this? Or should I be trying a different approach?
There's a Python module that has a function that does exactly what I want, but I would rather use Matlab. The description for the Python function is:
"mesh(x,y,z)
where x, y, z are 2D arrays, all of the same shape, giving the positions of the vertices of the surface. The connectivity between these points is implied by the connectivity on the arrays."
  3 件のコメント
Vincent Laroche
Vincent Laroche 2020 年 10 月 6 日
編集済み: Vincent Laroche 2020 年 10 月 6 日
Thank you! You were right, it took a bit of extra manipulation of the data, but I was able to create the tube surface using the patch('Faces',F,'Vertices',V) format.
Rik
Rik 2020 年 10 月 6 日
Would you like me to move my comment to the answer section, or do you want to post your own solution there?

サインインしてコメントする。

採用された回答

Vincent Laroche
Vincent Laroche 2020 年 10 月 6 日
It took a bit of extra manipulation of the data, but I was able to create the tube surface using the patch('Faces',F,'Vertices',V) format.

その他の回答 (1 件)

Jon
Jon 2020 年 10 月 6 日
There is also a MATLAB function called streamtube https://www.mathworks.com/help/matlab/ref/streamtube.html which seems closely related to your problem.

カテゴリ

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

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by