How to write/design a matrix similar to the one outputted by contourf
1 次查看(过去 30 天)
显示 更早的评论
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
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!