Here’s the source code for matlab:

</tr></table></code></figure>

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45</td>
function [ h ] = msubplot(m, n, p) h = subplot(m, n, p); hd = 1 / n; vd = 1 / m; minc = n; minr = m; maxc = 0; maxr = 0; for i = 1:prod(size(p)) col = mod(p(i), n); if col == 0 col = n; end row = ((p(i) - 1 - mod(p(i) - 1, n)) / n) + 1; if col > maxc maxc = col; end if row > maxr maxr = row; end if col < minc minc = col; end if row < minr minr = row; end end height = maxr - minr + 1; width = maxc - minc + 1; g = get(h, 'OuterPosition'); g(1) = (minc - 1) * hd; g(2) = (m - maxr) * vd; g(3) = width * hd; g(4) = height * vd; set(h, 'OuterPosition', g); end </pre></div>