0001 function varargout = plot(as, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 its = [];
0028 ifs = [];
0029 ic = [];
0030 ixy = [];
0031
0032
0033 hfig = [];
0034 handles = [];
0035
0036 si = size(as);
0037 na = si(1);
0038 nb = si(2);
0039
0040 for j=1:nb
0041 for i=1:na
0042
0043
0044 a = as(i,j);
0045 if iscell(a)
0046 a = a{1};
0047 end
0048 d = a.data;
0049 dinfo = whos('d');
0050 switch dinfo.class
0051 case 'tsdata'
0052 its = [its sub2ind(si, i, j)];
0053 case 'fsdata'
0054 ifs = [ifs sub2ind(si, i, j)];
0055 case 'cdata'
0056 ic = [ic sub2ind(si, i, j)];
0057 case 'xydata'
0058 ixy = [ixy sub2ind(si, i, j)];
0059 otherwise
0060 error('### unknown data type for analysis objects.')
0061 end
0062 end
0063 end
0064
0065
0066 [tfig, thandles] = ao_plot_tsdata(as(its), varargin);
0067 hfig = [hfig tfig];
0068 handles = [handles thandles];
0069
0070
0071 [tfig, thandles] = ao_plot_fsdata(as(ifs), varargin);
0072 hfig = [hfig tfig];
0073 handles = [handles thandles];
0074
0075
0076 [tfig, thandles] = ao_plot_cdata(as(ic), varargin);
0077 hfig = [hfig tfig];
0078 handles = [handles thandles];
0079
0080
0081 [tfig, thandles] = ao_plot_xydata(as(ixy), varargin);
0082 hfig = [hfig tfig];
0083 handles = [handles thandles];
0084
0085
0086 global sltpda_loop_plotTitle;
0087 if ~isempty(sltpda_loop_plotTitle)
0088 set(gcf, 'Name', sltpda_loop_plotTitle);
0089 end
0090
0091 if nargout == 1
0092 varargout{1} = handles;
0093 end
0094
0095
0096
0097
0098 function [hfig, handles] = ao_plot_fsdata(as, args)
0099
0100
0101
0102
0103 hfig = [];
0104 handles = [];
0105
0106
0107 view = 'mag/deg';
0108
0109
0110 while length(args) >= 2
0111 prop = args{1};
0112 val = args{2};
0113 args = args(3:end);
0114 switch prop
0115 case 'view'
0116 view = val;
0117 otherwise
0118 warning(sprintf('!!! unknown parameter %s - ignoring.', prop));
0119 end
0120
0121 end
0122
0123
0124 na = length(as);
0125 haveComplex = 0;
0126 logy = 0;
0127 for i=1:na
0128 a = as(i);
0129 d = a.data;
0130 if max(abs(d.xx))/min(abs(d.xx)) > 10
0131 logy = 1;
0132 end
0133 if ~isreal(d.xx)
0134 haveComplex = 1;
0135 end
0136 end
0137
0138 if na > 0
0139
0140 disp('--- plotting frequency-series data AO');
0141 colors = {[0.8 0.2 0.2], [0.2 0.2 0.8], [0.2 0.9 0.2],...
0142 [0.37 0.9 0.83], [0.888 0.163 0.9], [0 0 0], ...
0143 [0 207 255]/255, [255 128 0]/255, [143 0 0]/255,...
0144 [255 207 0]/255, [0.9 0.266 0.593]};
0145
0146
0147 legendStr = [];
0148
0149 for i=1:na
0150 a = as(i);
0151
0152
0153 d = a.data;
0154 f = d.f;
0155 xx = d.xx;
0156 col = colors{mod(i-1,length(colors))+1};
0157
0158
0159 if ~haveComplex
0160
0161 if length(d.enbw) == length(d.xx) && length(d.xx) > 1
0162 subplot(3,1,1:2)
0163 legendStr = [legendStr cellstr(sprintf('%s', ltpda_label(a.name)))];
0164 else
0165 legendStr = [legendStr cellstr(sprintf('%s\nenbw=%g', ltpda_label(a.name), d.enbw))];
0166 end
0167 if ~logy
0168 hp = semilogx(f, xx);
0169 else
0170 hp = loglog(f,xx);
0171 end
0172 set(hp, 'Color', col);
0173 hold on;
0174 title('Plot of frequency-series AOs');
0175 grid on;
0176 legend(legendStr)
0177 ylabel(sprintf('Amplitude [%s]', d.yunits));
0178 handles = [handles hp];
0179 set(gca, 'XScale', 'log');
0180 set(gca, 'YScale', 'log');
0181
0182
0183
0184 if length(d.enbw) == length(d.xx) && length(d.xx) > 1
0185 disp(' + making ENBW plot');
0186 subplot(3,1,3)
0187 hp = stairs(f, d.enbw);
0188 hold on;
0189 set(hp, 'Color', col);
0190 grid on;
0191 ylabel('ENBW [Hz]');
0192 handles = [handles hp];
0193 set(gca, 'XScale', 'log');
0194 set(gca, 'YScale', 'lin');
0195 end
0196
0197 xlabel(sprintf('Frequency [%s]', d.xunits));
0198
0199 else
0200
0201 switch view
0202 case 'mag/deg'
0203 subplot(3,1,1:2)
0204 if ~logy
0205 hp = semilogx(f, abs(xx));
0206 else
0207 hp = loglog(f,abs(xx));
0208 end
0209
0210
0211 set(hp, 'Color', col);
0212 hold on;
0213 legendStr = [legendStr cellstr(sprintf('%s', ltpda_label(a.name)))];
0214 title('Plot of complex frequency series AOs');
0215 grid on;
0216 handles = [handles hp];
0217 ylabel('Magnitude');
0218 legend(legendStr)
0219
0220
0221
0222 subplot(3,1,3)
0223 hp = semilogx(f, ltpda_phase(xx));
0224 set(hp, 'Color', col);
0225 hold on;
0226 grid on;
0227 xlabel(sprintf('Frequency [%s]', d.xunits));
0228 ylabel('Phase [deg]');
0229 handles = [handles hp];
0230
0231
0232
0233 case 're/im'
0234 subplot(2,1,1)
0235 hp = semilogx(f, real(xx));
0236 set(hp, 'Color', col);
0237 hold on;
0238 title('Plot of complex frequency series AOs');
0239 legendStr = [legendStr cellstr(sprintf('%s', ltpda_label(a.name)))];
0240 grid on;
0241 handles = [handles hp];
0242 ylabel('Real');
0243 legend(legendStr)
0244 set(gca, 'XScale', 'log');
0245 set(gca, 'YScale', 'lin');
0246
0247 subplot(2,1,2)
0248 hp = semilogx(f, imag(xx));
0249 set(hp, 'Color', col);
0250 hold on;
0251 grid on;
0252 xlabel(sprintf('Frequency [%s]', d.xunits));
0253 ylabel('Imag');
0254 handles = [handles hp];
0255 set(gca, 'XScale', 'log');
0256 set(gca, 'YScale', 'lin');
0257
0258 otherwise
0259 error('### unknown view for plotting complex fsdata.');
0260 end
0261 ltpda_allxaxis(min(f), max(f));
0262
0263 end
0264
0265 end
0266 end
0267
0268
0269
0270
0271
0272 function [hfig, handles] = ao_plot_tsdata(as, args)
0273
0274
0275
0276
0277
0278 hfig = [];
0279 handles = [];
0280
0281 na = length(as);
0282 if na > 0
0283
0284
0285 Toff = 1e20;
0286 for j=1:na
0287 t0 = ltpda_utc2gps(as(j).data.t0);
0288 if t0 < Toff
0289 Toff = t0;
0290 end
0291 end
0292
0293 disp('--- plotting time-series data AO');
0294 colors = {[0.8 0.2 0.2], [0.2 0.2 0.8], [0.2 0.9 0.2],...
0295 [0.37 0.9 0.83], [0.888 0.163 0.9], [0 0 0], ...
0296 [0 207 255]/255, [255 128 0]/255, [143 0 0]/255,...
0297 [255 207 0]/255, [0.9 0.266 0.593]};
0298
0299 handles = [];
0300
0301
0302 legendStr = [];
0303 for i=1:na
0304 a = as(i);
0305 if iscell(a)
0306 a = a{1};
0307 end
0308
0309 d = a.data;
0310 t0 = ltpda_utc2gps(a.data.t0);
0311 t = d.t + t0 - Toff;
0312 x = d.x;
0313
0314 col = colors{mod(i-1,length(colors))+1};
0315 hp = plot(t,x);
0316 set(hp, 'Color', col);
0317 hold on;
0318 legendStr = [legendStr cellstr(sprintf('%s - %s\n%d secs @ %gHz', ltpda_label(a.name), d.t0, d.nsecs, d.fs))];
0319
0320 title('Plot of time-series AOs');
0321 grid on;
0322 legend(legendStr)
0323 xlabel(sprintf('Time from %s [%s]', ltpda_gps2utc(Toff), d.xunits));
0324 ylabel(sprintf('Amplitude [%s]', d.yunits));
0325 set(gca, 'XScale', 'lin');
0326 set(gca, 'YScale', 'lin');
0327 handles = [handles hp];
0328 end
0329 end
0330
0331
0332
0333
0334 function [hfig, handles] = ao_plot_cdata(as, args)
0335
0336
0337
0338
0339
0340 hfig = [];
0341 handles = [];
0342
0343 na = length(as);
0344
0345 if na > 0
0346 disp('--- plotting cdata AO');
0347 colors = {[0.8 0.2 0.2], [0.2 0.2 0.8], [0.2 0.9 0.2],...
0348 [0.37 0.9 0.83], [0.888 0.163 0.9], [0 0 0], ...
0349 [0 207 255]/255, [255 128 0]/255, [143 0 0]/255,...
0350 [255 207 0]/255, [0.9 0.266 0.593]};
0351
0352 handles = [];
0353
0354
0355 legendStr = [];
0356 for i=1:na
0357 a = as(i);
0358 if iscell(a)
0359 a = a{1};
0360 end
0361
0362
0363 d = a.data;
0364 if isreal(d.vals)
0365 y = d.vals;
0366 x = 1:length(y);
0367 else
0368 x = real(d.vals);
0369 y = imag(d.vals);
0370 end
0371
0372 col = colors{mod(i-1,length(colors))+1};
0373 hp = plot(x,y,'o');
0374 set(hp, 'Color', col);
0375 hold on;
0376 legendStr = [legendStr cellstr(sprintf('%s', ltpda_label(a.name)))];
0377
0378 title('Plot of cdata AOs');
0379 grid on;
0380 legend(legendStr)
0381 if isreal(d.vals)
0382 xlabel('Sample');
0383 ylabel('Value');
0384 else
0385 xlabel('Real');
0386 ylabel('Imag');
0387 end
0388 set(gca, 'XScale', 'lin');
0389 set(gca, 'YScale', 'lin');
0390 end
0391 end
0392
0393
0394
0395
0396 function [hfig, handles] = ao_plot_xydata(as, args)
0397
0398
0399
0400
0401 hfig = [];
0402 handles = [];
0403
0404 na = length(as);
0405 if na > 0
0406 disp('--- plotting X-Y data AO');
0407 colors = {[0.8 0.2 0.2], [0.2 0.2 0.8], [0.2 0.9 0.2],...
0408 [0.37 0.9 0.83], [0.888 0.163 0.9], [0 0 0], ...
0409 [0 207 255]/255, [255 128 0]/255, [143 0 0]/255,...
0410 [255 207 0]/255, [0.9 0.266 0.593]};
0411
0412 handles = [];
0413
0414
0415 legendStr = [];
0416 for i=1:na
0417 a = as(i);
0418 if iscell(a)
0419 a = a{1};
0420 end
0421
0422 d = a.data;
0423 x = d.x;
0424 y = d.y;
0425
0426 col = colors{mod(i-1,length(colors))+1};
0427 hp = plot(x,y);
0428 set(hp, 'Color', col);
0429 hold on;
0430 legendStr = [legendStr cellstr(sprintf('%s', ltpda_label(a.name)))];
0431
0432 title('Plot of xydata AOs');
0433 grid on;
0434 legend(legendStr)
0435 xlabel(sprintf('X [%s]', d.xunits));
0436 ylabel(sprintf('Y [%s]', d.yunits));
0437 set(gca, 'XScale', 'lin');
0438 set(gca, 'YScale', 'lin');
0439 end
0440 end
0441
0442
0443
0444