comparison m-toolbox/m/gui/specwin_viewer/ltpda_specwin_viewer_build_window.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 ltpda_specwin_viewer_build_window(varargin)
2 % Function to build the window and display it.
3
4 plotType = varargin{end};
5
6 mainfig = findobj('Tag', 'LTPDAspecwin_viewer');
7 ax = getappdata(mainfig, 'axes');
8 info = findobj('Tag', 'LTPDA_specwin_viewer_wininfo');
9
10 % get window type
11 winTxt = findobj('Tag', 'LTPDA_specwin_viewer_WinType');
12 wins = get(winTxt, 'String');
13 win = wins{get(winTxt, 'Value')};
14
15 % Get window size
16 sizeTxt = findobj('Tag', 'LTPDA_specwin_viewer_WinSize');
17 winlen = str2num(get(sizeTxt, 'String'));
18
19 if strcmpi(win, 'Kaiser')
20 % get psll
21 psllTxt = findobj('Tag', 'LTPDA_specwin_viewer_PSLL');
22 psll = str2num(get(psllTxt, 'String'));
23 w = specwin(win, winlen, psll);
24 cstr = sprintf('specwin(''%s'', %d, %f)', win, winlen, psll);
25 else
26 w = specwin(win, winlen);
27 cstr = sprintf('specwin(''%s'', %d)', win, winlen);
28 end
29
30 consTxt = findobj(mainfig, 'Tag', 'LTPDA_specwin_viewer_cstr');
31 set(consTxt, 'String', cstr);
32
33
34 titleStr = '';
35 legendStr = '';
36
37 switch plotType
38 case 'Time-domain'
39 hl = plot(ax, 1:length(w.win), w.win);
40 xlabel('sample');
41 ylabel('amplitude');
42 case 'Freq-domain'
43 % Freq response
44 f = linspace(-30,30,1000);
45 r = zeros(size(f));
46 N = length(w.win);
47
48 % do dft
49 for j=1:length(f)
50 k = [0:N-1].';
51 r(j) = (w.win * exp(-2*pi*1i*f(j)*k/N) )./w.ws;
52 end
53
54 % convert to dB
55 dbr = 20*log10(abs(r)); hl = plot(ax, f, dbr);
56 xlabel('bin');
57 ylabel('amplitude [dB]');
58 end
59
60 col = [0.8 0.1 0.1];
61 set(hl, 'Color', col);
62 titleStr = [titleStr, utils.plottools.label(w.type), ', '];
63 titleStr = titleStr(1:end-2);
64 title(sprintf('Window: %s', titleStr));
65 axis tight
66 grid on
67
68
69 % Info string
70 lstr = [sprintf('alpha = %g\n', w.alpha)...
71 sprintf('psll = %g\n', w.psll)...
72 sprintf('rov = %g\n', w.rov)...
73 sprintf('nenbw = %g\n', w.nenbw)...
74 sprintf('w3db = %g\n', w.w3db)...
75 sprintf('flatness = %g\n', w.flatness)];
76 legendStr = [legendStr cellstr(lstr)];
77 set(info, 'String', legendStr);
78
79 % Constructor
80
81
82
83
84