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('!!! 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
0286
0287 end
0288
0289 end
0290 end
0291
0292
0293
0294
0295
0296 function [hfig, handles] = ao_plot_tsdata(as, args)
0297
0298
0299
0300
0301
0302 hfig = [];
0303 handles = [];
0304 lenLegend = getappdata(0, 'wraplegendstringat');
0305
0306 na = length(as);
0307 if na > 0
0308
0309
0310 Toff = 1e20;
0311 for j=1:na
0312 t0 = as(j).data.t0.utc_epoch_milli/1000;
0313 if t0 < Toff
0314 Toff = t0;
0315 end
0316 end
0317
0318 disp('--- plotting time-series data AO');
0319 colors = getappdata(0,'ltpda_default_plot_colors');
0320
0321 handles = [];
0322
0323
0324 legendStr = [];
0325 for i=1:na
0326 a = as(i);
0327 if iscell(a)
0328 a = a{1};
0329 end
0330
0331 d = a.data;
0332 t0 = a.data.t0.utc_epoch_milli/1000;
0333 t = d.t + t0 - Toff;
0334 x = d.x;
0335
0336 col = colors{mod(i-1,length(colors))+1};
0337 hp = plot(t,x);
0338 set(hp, 'Color', col);
0339 hold on;
0340 legendStr = [legendStr...
0341 cellstr([wrapLegendString(sprintf('%s', ltpda_label(a.name)), lenLegend)...
0342 sprintf('\n%s\n%6.2f secs @ %gHz', char(d.t0), d.nsecs, d.fs)])];
0343
0344 title('Plot of time-series AOs');
0345 grid on;
0346 legend(legendStr)
0347 xlabel(sprintf('Time from %s [%s]', char(time(Toff*1000)), d.xunits));
0348 ylabel(sprintf('Amplitude [%s]', d.yunits));
0349 set(gca, 'XScale', 'lin');
0350 set(gca, 'YScale', 'lin');
0351 handles = [handles hp];
0352 end
0353 end
0354
0355
0356
0357
0358 function [hfig, handles] = ao_plot_cdata(as, args)
0359
0360
0361
0362
0363
0364 hfig = [];
0365 handles = [];
0366 lenLegend = getappdata(0, 'wraplegendstringat');
0367
0368 na = length(as);
0369
0370 if na > 0
0371 disp('--- plotting cdata AO');
0372 colors = getappdata(0,'ltpda_default_plot_colors');
0373
0374 handles = [];
0375
0376
0377 legendStr = [];
0378 for i=1:na
0379 a = as(i);
0380 if iscell(a)
0381 a = a{1};
0382 end
0383
0384
0385 d = a.data;
0386 if isreal(d.vals)
0387 y = d.vals;
0388 x = 1:length(y);
0389 else
0390 x = real(d.vals);
0391 y = imag(d.vals);
0392 end
0393
0394 col = colors{mod(i-1,length(colors))+1};
0395 hp = plot(x,y,'o');
0396 set(hp, 'Color', col);
0397 hold on;
0398 legendStr = [legendStr cellstr(wrapLegendString(sprintf('%s', ltpda_label(a.name)), lenLegend))];
0399
0400 title('Plot of cdata AOs');
0401 grid on;
0402 legend(legendStr)
0403 if isreal(d.vals)
0404 xlabel('Sample');
0405 ylabel('Value');
0406 else
0407 xlabel('Real');
0408 ylabel('Imag');
0409 end
0410 set(gca, 'XScale', 'lin');
0411 set(gca, 'YScale', 'lin');
0412 end
0413 end
0414
0415
0416
0417
0418 function [hfig, handles] = ao_plot_xydata(as, args)
0419
0420
0421
0422
0423 hfig = [];
0424 handles = [];
0425 lenLegend = getappdata(0, 'wraplegendstringat');
0426
0427 na = length(as);
0428 if na > 0
0429 disp('--- plotting X-Y data AO');
0430 colors = getappdata(0,'ltpda_default_plot_colors');
0431
0432 handles = [];
0433
0434
0435 legendStr = [];
0436 for i=1:na
0437 a = as(i);
0438 if iscell(a)
0439 a = a{1};
0440 end
0441
0442 d = a.data;
0443 x = d.x;
0444 y = d.y;
0445
0446 col = colors{mod(i-1,length(colors))+1};
0447 hp = plot(x,y);
0448 set(hp, 'Color', col);
0449 hold on;
0450 legendStr = [legendStr cellstr(wrapLegendString(sprintf('%s', ltpda_label(a.name)), lenLegend))];
0451
0452 title('Plot of xydata AOs');
0453 grid on;
0454 legend(legendStr)
0455 xlabel(sprintf('X [%s]', d.xunits));
0456 ylabel(sprintf('Y [%s]', d.yunits));
0457 set(gca, 'XScale', 'lin');
0458 set(gca, 'YScale', 'lin');
0459 end
0460 end
0461
0462
0463
0464
0465 function so = wrapLegendString(s, N)
0466
0467
0468 sc = wrapstring(s, N);
0469
0470 so = sc{1};
0471
0472 for j=2:length(sc)
0473 so = [so sprintf('\n%s', sc{j})];
0474 end
0475
0476
0477
0478
0479
0480 function pl_default = getDefaultPL()
0481
0482 disp('* creating default plist...');
0483 pl_default = plist();
0484 disp('* done.');
0485
0486