Clear Filters
Clear Filters

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

2 views (last 30 days)
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] 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
Adam Danz
Adam Danz on 21 Sep 2021
Edited: Adam Danz on 21 Sep 2021
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.

Sign in to comment.

Answers (0)


Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!