I have a data set consisting of xcoord, ycoord, and density in vectors, exported from Fluent. I would like to be able to view the data as an m x n matrix, rather than as a surface plot, surf(X,Y,Z), so that I can access specific elements of that matrix directly. (i.e., I would like to be able to say density(ii,jj) = ....). I've tried many methods for doing this, and all have resulted in a skewed looking plot.

1 件のコメント

Walter Roberson
Walter Roberson 2018 年 10 月 20 日
編集済み: Walter Roberson 2018 年 10 月 20 日
view(2); for the viewing.
griddata for the array of values.

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

 採用された回答

Star Strider
Star Strider 2018 年 10 月 20 日

0 投票

You did not say what you have tried, and what did not work.
Consider:
Z = randn(100);
figure
surf(Z)
view(0,90)
That produces a (100x100) matrix, and the view call lets you look at it from the top, rather than from the side.

4 件のコメント

Jonathan Wells
Jonathan Wells 2018 年 10 月 20 日
I know about view, but I don't need to simply see the resulting surface from a top view. I need to be able to access specific points on the matrix. For instance, I need to be able to access Density(ii,jj), and I cannot do that using the x,y,and z coordinate version of surf, unless there is a way I don't know about. Is there a way to say Z(x(ii,jj),y(ii,jj)) where I can actually return the index of x(ii,jj) and y(ii,jj)?
I've tried using scatteredInterpolant, making a new meshgrid with integer coordinates, sorting and reshaping vectors, and probably a few more I'm forgetting.
The problem is that the plot from surf(Z) does not match the plot of surf(X,Y,Z), and I need something to make it to where it does.
Star Strider
Star Strider 2018 年 10 月 20 日
Walter Roberson in his comment mentioned the griddata (link) function as a way to easily access any ‘Z’ values by their ‘X’ and ‘Y’ values. Unless you have a function that accurately describes your data (so you can use it to calculate ‘Z’ from the others), I would begin with griddata. You can probably create an anonymous function using it if you need to.
Jonathan Wells
Jonathan Wells 2018 年 10 月 20 日
I must have overlooked that the first time, but griddata did the trick! Thank you both so much :)
Star Strider
Star Strider 2018 年 10 月 20 日
Our pleasure!

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by