热度 21
2013-10-6 18:34
2516 次阅读|
0 个评论
博客测试 插图测试 不管怎么说,EDN的博客是越做越好,而且编辑器的功能也日益强大。 edn的确是用心在做这个事情了,打从两年前网站重新改版了一次之后,折腾的有点乱,现在似乎是又变得好起来。 这代码格式还做的真漂亮。 就是插图还有点分辨率太低,也许是服务器压力太大吧。要是能够把插图的分辨率再提高上来就完美了。不过说来也奇怪,那些神马乱七八糟的论坛,各种扯淡的高清大图都能够上传,为嘛这种专业的电子技术网站博客却不行呢,我们还是码农电工呢。 再观望一段时间吧。 以下是代码片段: %/////////////////////////////////////////////////////////// % DFT analyse of sampled sine signal %/////////////////////////////////////////////////////////// close all; clear; clc; % generate 2 sampled sine signals with different frequency freq_x1 = 5.1E3 ; % frequency of signal x1 amp_x1 = 10 ; % amptitude of signal x1 freq_x2 = 80E3 ; % frequency of signal x2 amp_x2 = 3 ; % amptitude of signal x2 data_len = 1024 ; fs = 512E3 ; % sample rate kaiser_beta = 8 ; % beta of kaiser win idx_n = ; % n index idx_n = idx_n .' ; % we need column vector idx_t = idx_n/fs ; % time index idx_phase_x1 = 2*pi*idx_n*freq_x1/fs; % x1 phase index x1 = sin(idx_phase_x1); idx_phase_x2 = 2*pi*idx_n*freq_x2/fs; % x2 phase index x2 = sin(idx_phase_x2); % signal x is consisted of x1 and x2; x = x1+x2; % plot them, use time label figure; set(gca,'fontsize',16); % get window function data win = kaiser(data_len, kaiser_beta); % windowing the data win_x = win .* x; subplot(4,1,1);plot(idx_t, x1 );grid on;title('x1', 'fontsize', 14); subplot(4,1,2);plot(idx_t, x2 );grid on;title('x2', 'fontsize', 14); subplot(4,1,3);plot(idx_t, x );grid on;title('x=x1+x2', 'fontsize', 14); subplot(4,1,4);plot(idx_t, win_x);grid on;title('windowed x', 'fontsize', 14); % perform fft x_fft = fft(win_x) ; % get frequency index idx_freq = -fs/2 + idx_n .* (fs / data_len); % shift zero frequency to the data center x_fft = fftshift(x_fft); %^ idx_freq = fftshift(idx_freq); % map to amptitude dB scale x_fft_abs = abs(x_fft); x_fft_abs_dB = 20*log10(x_fft_abs + 1E-8); % normalize the spectrum from 0 dB; max_dB = max(x_fft_abs_dB); norm_spectrum = x_fft_abs_dB - max_dB; figure; plot(idx_freq, norm_spectrum);grid on; title('normlized spectrum of x', 'fontsize', 14); 还是用图片来保持排版,数学符号最难办了噢