How to write/design a matrix similar to the one outputted by contourf

3 ビュー (過去 30 日間)
sparsh garg
sparsh garg 2021 年 9 月 21 日
コメント済み: sparsh garg 2021 年 9 月 21 日
So the output of contourf is a matrix of 2xN dimension as described here
Contour matrix, returned as two-row matrix. This matrix contains the contour levels (heights) and the coordinates of the vertices at each level. The data is arranged sequentially in n sets of columns for n contour lines:
  • The first column in each set contains the contour level and the number of vertices at that level. The top number is the contour level, and the bottom number is the number of vertices.
  • Subsequent columns in the set are the (x, y) coordinates of the vertices. Each column represents an ordered pair. The top number is the x-coordinate, and the bottom number is the y-coordinate.
Now let's say that I have a set of points ,I would like to organize them in a similar manner described above
for example let's say i have 1200 points
i want matrix to look like this
[first column] S.no 1 no of points 500
then 501st column S no 2 no of points 400
and finally 901 column S no 3 no of points 300
Would a strucutre or a class be better suited.
the class can have a method which retrieves the desired no of points for the particular S no
  6 件のコメント
Adam Danz
Adam Danz 2021 年 9 月 21 日
編集済み: Adam Danz 2021 年 9 月 21 日
Instead of concatenating the 2xN coordinates along the second dimension, if N is equal for all circles, then I would concatenate them along the 3rd dimension using cat(3,___). If N is not equal for all circles, I would store each set of coordinates in a 1xN or Nx1 cell array.
Note that your description differs from the contour output in that your data are coordinates whereas the contour output contains level and number-of-verticies which is does not intuitively provide coordinate information.
sparsh garg
sparsh garg 2021 年 9 月 21 日
yes i think that might work,i will try it .

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by