0001 function R = tunespaceplot(XTUNE,YTUNE,RESORDER,varargin);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 if nargin>3
0022 if ishandle(varargin{1}) & strcmp(get(varargin{1},'Type'),'figure')
0023
0024 figure(varargin{1});
0025 else
0026 figure
0027 axes;
0028 end
0029 end
0030 if nargin>4
0031 LINEARGS = varargin(2:end);
0032 else
0033 LINEARGS = {};
0034 end
0035
0036
0037 axis([XTUNE,YTUNE]);
0038 axis square
0039
0040
0041 R = zeros(8*length(RESORDER),6);
0042 NLMAX = 0;
0043 for r = RESORDER
0044 for m = 0:r
0045 n = r-m;
0046
0047
0048 p1 = ceil(m*XTUNE(1)+n*YTUNE(1));
0049 p2 = floor(m*XTUNE(2)+n*YTUNE(1));
0050
0051
0052 for p =p1:p2
0053 if m
0054 NLMAX = NLMAX+1;
0055 R(NLMAX,:) = [abs(m)+abs(n),m,n,p,(p-n*YTUNE(1))/m,YTUNE(1)];
0056 end
0057 end
0058
0059
0060 p1 = ceil(m*XTUNE(1)+n*YTUNE(1));
0061 p2 = floor(m*XTUNE(1)+n*YTUNE(2));
0062
0063
0064 for p =p1:p2
0065 if n
0066 NLMAX = NLMAX+1;
0067 R(NLMAX,:) = [abs(m)+abs(n),m,n,p,XTUNE(1),(p-m*XTUNE(1))/n];
0068 end
0069 end
0070
0071
0072 p1 = ceil(m*XTUNE(1)+n*YTUNE(2));
0073 p2 = floor(m*XTUNE(2)+n*YTUNE(2));
0074
0075 for p=p1:p2
0076 if m
0077 NLMAX = NLMAX+1;
0078 R(NLMAX,:) = [abs(m)+abs(n),m,n,p,(p-n*YTUNE(2))/m,YTUNE(2)];
0079 end
0080 end
0081
0082
0083 p1 = ceil(m*XTUNE(2)+n*YTUNE(1));
0084 p2 = floor(m*XTUNE(2)+n*YTUNE(2));
0085
0086 for p=p1:p2
0087 if n
0088 NLMAX = NLMAX+1;
0089 R(NLMAX,:) = [abs(m)+abs(n),m,n,p,XTUNE(2),(p-m*XTUNE(2))/n];
0090 end
0091 end
0092
0093
0094 n = -r+m;
0095
0096
0097 p1 = ceil(m*XTUNE(1)+n*YTUNE(1));
0098 p2 = floor(m*XTUNE(2)+n*YTUNE(1));
0099
0100 for p =p1:p2
0101 if m
0102 NLMAX = NLMAX+1;
0103 R(NLMAX,:) = [abs(m)+abs(n),m,n,p,(p-n*YTUNE(1))/m,YTUNE(1)];
0104 end
0105 end
0106
0107
0108
0109 p1 = floor(m*XTUNE(1)+n*YTUNE(1));
0110 p2 = ceil(m*XTUNE(1)+n*YTUNE(2));
0111
0112 for p =p2:p1
0113 if n
0114 NLMAX = NLMAX+1;
0115 R(NLMAX,:) = [abs(m)+abs(n),m,n,p,XTUNE(1),(p-m*XTUNE(1))/n];
0116 end
0117 end
0118
0119
0120 p1 = ceil(m*XTUNE(1)+n*YTUNE(2));
0121 p2 = floor(m*XTUNE(2)+n*YTUNE(2));
0122
0123 for p=p1:p2
0124 if m
0125 NLMAX = NLMAX+1;
0126 R(NLMAX,:) = [abs(m)+abs(n),m,n,p,(p-n*YTUNE(2))/m,YTUNE(2)];
0127 end
0128 end
0129
0130
0131
0132
0133 p1 = floor(m*XTUNE(2)+n*YTUNE(1));
0134 p2 = ceil(m*XTUNE(2)+n*YTUNE(2));
0135 for p=p2:p1
0136 if n
0137 NLMAX = NLMAX+1;
0138 R(NLMAX,:) = [abs(m)+abs(n),m,n,p,XTUNE(2),(p-m*XTUNE(2))/n];
0139 end
0140 end
0141 end
0142 end
0143
0144 R = unique(R(1:NLMAX,:),'rows');
0145 [temp,I,J] = unique(R(:,1:4),'rows');
0146 K = I(find(diff([0;I])==2))-1;
0147
0148 RESNUM = [R(K,1:4)];
0149 X1 = R(K,5);
0150 X2 = R(K+1,5);
0151 Y1 = R(K,6);
0152 Y2 = R(K+1,6);
0153
0154
0155
0156 K1 = (X1==X2) & (X1==XTUNE(1));
0157 K2 = (X1==X2) & (X1==XTUNE(2));
0158 K3 = (Y1==Y2) & (Y1==YTUNE(1));
0159 K4 = (Y1==Y2) & (Y1==YTUNE(2));
0160
0161 K = find(~(K1 | K2 | K3 | K4));
0162
0163
0164 RESNUM = RESNUM(K,:);
0165 X1 = X1(K);
0166 X2 = X2(K);
0167 Y1 = Y1(K);
0168 Y2 = Y2(K);
0169
0170
0171 R = [RESNUM,X1,Y1,X2,Y2];
0172
0173
0174
0175
0176
0177
0178 NL = size(RESNUM,1);
0179 for i = 1:NL
0180 hl = line([X1(i) X2(i)],[Y1(i) Y2(i)]);
0181 if ~isempty(LINEARGS)
0182 set(hl,LINEARGS{:});
0183 end
0184 end
0185
0186
0187