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