1 | function h = subfig(a, b, c, h) |
---|
2 | %SUBFIG - Pops the current axes into a separate figure |
---|
3 | % h = subfig(s1, s2, s3, h_fig) |
---|
4 | % |
---|
5 | % Written by Greg Portmann |
---|
6 | |
---|
7 | |
---|
8 | if nargin < 3 |
---|
9 | error('3 inputs required'); |
---|
10 | end |
---|
11 | if nargin < 4 |
---|
12 | h = figure; |
---|
13 | else |
---|
14 | h = figure(h); |
---|
15 | end |
---|
16 | |
---|
17 | s = get(0, 'ScreenSize'); |
---|
18 | |
---|
19 | xbuf = .02 * s(3); |
---|
20 | ybuf = .06 * s(4); |
---|
21 | |
---|
22 | CommandWindowUnits = get(0,'Units'); |
---|
23 | FigUnits = get(h,'Units'); |
---|
24 | set(h,'Units', CommandWindowUnits); |
---|
25 | |
---|
26 | |
---|
27 | Nx = 5; |
---|
28 | Ny = 2; |
---|
29 | if a == 1 & b == 1 |
---|
30 | set(h, 'Position',[Nx*xbuf Ny*ybuf s(3)-2*Nx*xbuf s(4)-2*Ny*ybuf]); |
---|
31 | |
---|
32 | elseif a == 2 & b ==2 |
---|
33 | if c == 1 |
---|
34 | set(h, 'Position',[ xbuf s(4)/2+.5*ybuf s(3)/2-1*xbuf s(4)/2-2*ybuf]); |
---|
35 | elseif c == 2 |
---|
36 | set(h, 'Position',[s(3)/2+xbuf/2 s(4)/2+.5*ybuf s(3)/2-1*xbuf s(4)/2-2*ybuf]); |
---|
37 | elseif c == 3 |
---|
38 | set(h, 'Position',[ xbuf ybuf s(3)/2-1*xbuf s(4)/2-2*ybuf]); |
---|
39 | elseif c == 4 |
---|
40 | set(h, 'Position',[s(3)/2+xbuf/2 ybuf s(3)/2-1*xbuf s(4)/2-2*ybuf]); |
---|
41 | end |
---|
42 | elseif a == 1 & b ==2 |
---|
43 | if c == 1 |
---|
44 | set(h, 'Position',[ xbuf Ny*ybuf s(3)/2-1*xbuf s(4)-2*Ny*ybuf]); |
---|
45 | elseif c == 2 |
---|
46 | set(h, 'Position',[s(3)/2+xbuf/2 Ny*ybuf s(3)/2-1*xbuf s(4)-2*Ny*ybuf]); |
---|
47 | elseif c == 3 |
---|
48 | set(h, 'Position',[ xbuf Ny*ybuf s(3)/2-1*xbuf s(4)-2*Ny*ybuf]); |
---|
49 | elseif c == 4 |
---|
50 | set(h, 'Position',[s(3)/2+xbuf/2 Ny*ybuf s(3)/2-1*xbuf s(4)-2*Ny*ybuf]); |
---|
51 | end |
---|
52 | end |
---|
53 | |
---|
54 | set(h,'Units', FigUnits); |
---|
55 | |
---|