MATLAB Answers

How to make subplot accept the positions like matrix?

23 views (last 30 days)
Zeynab Mousavikhamene
Zeynab Mousavikhamene on 28 Feb 2020
Edited: gaetawoo on 29 Jul 2021 at 2:08
Assume there is 3*3 subplot, subplot(3,3,p) which p gives the location like 1,2,... from left to right and so on. How can I set the p to accept value of the position like the matrix indexing. For example for the 1st subplot, instead of 1, p=(1,1) which shows the xth and yth of the subplot position.
Any idea?

Accepted Answer

Adam
Adam on 28 Feb 2020
doc ind2sub
This will convert linear indices to n-dimensional subscripts.
e.g.
[p(1), p(2)] = ind2sub( [3, 3], 2 );
  2 Comments
gaetawoo
gaetawoo on 28 Jul 2021 at 21:05
tiledlayout is still, infuriatingly, row-major.
Update: I looked deeper and there is a tiledlayout property that lets you chooose row or column major. "TileIndexing" so.. yea. i guess it is the solution.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!