Mercurial > hg > ltpda
comparison m-toolbox/classes/@specwinViewer/plotWindow.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function plotWindow(varargin) | |
2 | |
3 if nargin == 2 | |
4 mainfig = varargin{end-1}; | |
5 plotType = varargin{end}; | |
6 ax = getappdata(mainfig.handle, 'axes'); | |
7 elseif nargin == 3 | |
8 ax = varargin{1}; | |
9 mainfig = varargin{2}; | |
10 plotType = varargin{3}; | |
11 end | |
12 | |
13 | |
14 info = findobj(mainfig.handle, 'Tag', 'InfoDisplay'); | |
15 | |
16 % get window type | |
17 winTxt = findobj(mainfig.handle, 'Tag', 'WindowSelect'); | |
18 wins = get(winTxt, 'String'); | |
19 win = wins{get(winTxt, 'Value')}; | |
20 | |
21 % Get window size | |
22 sizeTxt = findobj(mainfig.handle, 'Tag', 'WindowSize'); | |
23 winlen = str2num(get(sizeTxt, 'String')); | |
24 | |
25 if strcmpi(win, 'Kaiser') | |
26 % get psll | |
27 psllTxt = findobj(mainfig.handle, 'Tag', 'WindowPSLL'); | |
28 psll = str2num(get(psllTxt, 'String')); | |
29 w = specwin(win, winlen, psll); | |
30 cstr = sprintf('specwin(''%s'', %d, %f)', win, winlen, psll); | |
31 else | |
32 w = specwin(win, winlen); | |
33 cstr = sprintf('specwin(''%s'', %d)', win, winlen); | |
34 end | |
35 | |
36 consTxt = findobj(mainfig.handle, 'Tag', 'ConstructorDisplay'); | |
37 set(consTxt, 'String', cstr); | |
38 | |
39 | |
40 titleStr = ''; | |
41 legendStr = ''; | |
42 | |
43 switch plotType | |
44 case 'Time-domain' | |
45 hl = plot(ax, 1:length(w.win), w.win); | |
46 xlabel('sample'); | |
47 ylabel('amplitude'); | |
48 case 'Freq-domain' | |
49 % Freq response | |
50 f = linspace(-30,30,1000); | |
51 r = zeros(size(f)); | |
52 N = length(w.win); | |
53 | |
54 % do dft | |
55 for j=1:length(f) | |
56 k = [0:N-1].'; | |
57 r(j) = (w.win * exp(-2*pi*1i*f(j)*k/N) )./w.ws; | |
58 end | |
59 | |
60 % convert to dB | |
61 dbr = 20*log10(abs(r)); hl = plot(ax, f, dbr); | |
62 xlabel('bin'); | |
63 ylabel('amplitude [dB]'); | |
64 end | |
65 | |
66 col = [0.8 0.1 0.1]; | |
67 set(hl, 'Color', col); | |
68 titleStr = [titleStr, utils.plottools.label(w.type), ', ']; | |
69 titleStr = titleStr(1:end-2); | |
70 title(sprintf('Window: %s', titleStr)); | |
71 axis tight | |
72 grid on | |
73 | |
74 | |
75 % Info string | |
76 lstr = [sprintf('alpha = %g\n', w.alpha)... | |
77 sprintf('psll = %g\n', w.psll)... | |
78 sprintf('rov = %g\n', w.rov)... | |
79 sprintf('nenbw = %g\n', w.nenbw)... | |
80 sprintf('w3db = %g\n', w.w3db)... | |
81 sprintf('flatness = %g\n', w.flatness)]; | |
82 legendStr = [legendStr cellstr(lstr)]; | |
83 set(info, 'String', legendStr); | |
84 | |
85 | |
86 end |