首页 > 其他分享 >Signal Filters Design Based on Digital Signal Processing

Signal Filters Design Based on Digital Signal Processing

时间:2023-10-30 19:56:12浏览次数:35  
标签:Hz fs Based Signal Processing sampling frequency txt signal

Thoeries

I. Fourier Series Expansion Algorithm

We can utilize the Fourier Series to produce the analog signal with some frequency components. For any signal, its Fourier series expansion is defined as

\[x(t) = \frac{A_0}{2}+\sum_{n=1}^{\infty}A_n\cos(n\Omega t+\varphi_n) \]

In the equation,\(\frac{A_0}{2}\) represents the DC component, \(A_1\cos(\Omega t+\varphi_1)\), represents the fundamental component of the signal, \(A_n\cos(n\Omega t+\varphi_n)\) represents the nth harmonic component of the signal. Moreover, analog angular frequency \(\Omega = \frac{2\pi}{T}=2\pi f\).
Therefore, in this project we select three different frequency components, that is \(f_1, f_2, f_3\), to synthesize the final required analog signal:

\[x(t) = \frac{A_0}{2}+A_1\cos(2\pi f_1t+\varphi_1)+A_2\cos(2\times 2\pi f_2t+\varphi_2)+A_3\cos(3\times 2\pi f_3t+\varphi_3) \]

For simplicity, there we respectively select these values:

$A_0=0, A_1=1, A_2=1, A_3=1$
$$ \varphi_1=\varphi_2=\varphi_3=0 $$ Following above expression, we can get the generated analog signal: $$ x(t) = \cos(2\pi f_1t)+\cos(4\pi f_2t)+\cos(6\pi f_3t) $$

II. Sample the Analog Signal

Time Domain Sampling Theorem

According to the time domain sampling theorem, the sampling frequency must be greater than twice the signal cutoff frequency.
Let's assume that the sampling frequency is \(F_s\), and the generated analog signal frequency satisfies: \(F_1<F_2<F_3\), so the signal cutoff frequency is \(F_c = F_3\). The sampling theorem is formally expressed as:

\[F_s > 2F_c \]

In this experiment,we respectively selected \(F_1=10Hz, F_2=20Hz, F_3=30Hz\) to produce analog signal. So we can get the period and cutoff frequency of sampled signal:

\[T_c = \frac{1}{F_1}=0.1s, F_c = F_3 = 30Hz \]

Time-domain Window

For periodic continuous signals, we intercept at integer multiples of the period to obtain a sequence for spectrum analysis.

\[T_p=N*T_c, N\in Z^+ \]

Sampling Frequency

For a specific sampling frequency, we can get the sampling period \(T_s\), and the number of sampling points \(N\):

\[T_s = \frac{1}{F_s}, N=T_p*F_c \]

Therefore, we use sampling frequency of \(F_s=90Hz, F_s=60Hz, F_s=40Hz\) to get time-domain signals.

Spectral Resolution

Spectral resolution is defined as the minimum separation between two signals of different frequencies:

\[\Delta f = \frac{F_s}{N}=\frac{1}{NT_s}=\frac{1}{T_p} \]

III. Spectral Analysis

In this section, we will analyse the Amplitude-Frequency Characteristics and Phase-Frequency Characteristics of the sampled signal.

Convert to Frequency

When analysing the spectral, we need to convert the \(0\sim N-1\) to frequency sequence:

\[f_k = k*\frac{F_s}{N}, k=0,1,...N-1 \]

Convert to Real Amplitude

After we apply Discrete Fourier Transform to the sampled signal, the frequency-domain signal is complex-valued. And due to the time-domain signal is real-valued, the the frequency-domain signal is conjugate symmetric:

\[X(k) = X^*(N-k), k=0,1,...N-1 \]

For complex values, that means its real part is even symmetric about the middle point, and its imaginary part is odd symmetric about the middle point. This will be showed in the following figures.

Experiments

Experiment I: \(T_p=3T_c, F_s=90\)Hz

  • Samping Frequency \(F_s = 3F_c(F_s > 2F_c)\)
    We use the sampling frequency of \(F_s=90\)Hz under the condition of \(T_p=3T_c\).
Sampled Signal
Spectral Analysis Graph
  • Conclusions
    The sampling frequency satisfies the Time Domain Sampling Theorem so we can see there is no overlap in frequency domain about the amplitude-frequency characteristic. And when \(f=10\)Hz, \(f=20\)Hz, \(f=30\)Hz, we can get the amplitude very close to \(1\) which is us defined in analop signal.

Experiment II: \(T_p=3T_c, F_s=60\)Hz

  • Samping Frequency \(F_s = 2F_c(F_s = 2F_c)\)
    We use the sampling frequency of \(F_s=60\)Hz under the condition of \(T_p=3T_c\).
Sampled Signal
Spectral Analysis Graph
  • Conclusions
    The sampling frequency equals the threhold of Time Domain Sampling Theorem so we can easily see that it will just become overlapping in frequency domain. And when \(f=30\)Hz that is also \(F_s/2\) point, we can get this point very close to its symmetric frequency point.

Experiment III: \(T_p=3T_c, F_s=40\)Hz

  • Samping Frequency \(F_s = \frac{4}{3}F_c(F_s < 2F_c)\)
    We use the sampling frequency of \(F_s=40\)Hz under the condition of \(T_p=3T_c\).
Sampled Signal
Spectral Analysis Graph
  • Conclusions
    The sampling frequency do not equal the Time Domain Sampling Theorem so we can obviously see that it has discarded the third frequency \(f=30\)Hz, which is caused by overlapping in frequency domain.

Note: in order to clearly analyse spectral of sampled signal, we also select the Time-domain Window of \(T_p=50T_c\) to conduct experiments.

Experiment IV: \(T_p=50T_c, F_s=90\)Hz

Sampled Signal
Spectral Analysis Graph

Experiment V: \(T_p=50T_c, F_s=60\)Hz

Sampled Signal
Spectral Analysis Graph

Experiment VI: \(T_p=50T_c, F_s=40\)Hz

Sampled Signal
Spectral Analysis Graph

Codes

%% Project Introdection:
%   This project is developed to design some signal filters based on digital
% signal processing.
clear, close all;
%% Produce and sample digital signal
f1 = 10;
f2 = 20;
f3 = 30;      % so the fc = f3 = 30Hz
Np = 3;      % number of periods for time-domain window
%% Experiment 1 (Choosing samling frequency fs = 3fc (fs > 2fs))
fs = 90;          % sampling frequency
xn1 = ProduceSamplingSignal(f1, f2, f3, fs, Np);
DFTAnalysis(xn1, fs);

%% Experiment 2 (Choosing samling frequency fs = 2fc)
fs = 60;          % sampling frequency
xn2 = ProduceSamplingSignal(f1, f2, f3, fs, Np);
DFTAnalysis(xn2, fs);

%% Experiment 3 (Choosing samling frequency fs < 2fc)
fs = 40;          % sampling frequency
xn3 = ProduceSamplingSignal(f1, f2, f3, fs, Np);
DFTAnalysis(xn3, fs);
function xn = ProduceSamplingSignal(f1, f2, f3, fs, Np)
% Function Description: 
%        We want to make a digital signal composed of three frequency
%        components and sample the produced signal.
% Inputs: 
%        f1, f2, f3: means our selected frequency components, fs
%            represents the sampling frequency.
%        Np: means the number of periods.
% Outputs:
%        xn: represents the sampled signal.

    period = 1/f1;        % the period of analog signal(assuming f1 is the minimal)
    T = Np*period;         % sampling time-domain window(several periods)
    Ts = 1 / fs;          % sampling timestep
    t0 = 0: Ts : T;       % samping sequence of discrete sampling points
    t = 0: 0.0001: T;     % analog time sequence

    % Step I: Produce digital signal
    xt = cos(2*pi*f1*t) + cos(2*pi*f2*t) + cos(2*pi*f3*t);
    % Step II: Sample produced signal
    xn = cos(2*pi*f1*t0) + cos(2*pi*f2*t0) + cos(2*pi*f3*t0);

    % Step III: Visualize produced signal and sampled signal
    figure;
    subplot(2, 1, 1);
    plot(t, xt);
    txt = title('Time-domain signal $x(t)$');
    set(txt, 'Interpreter', 'latex');
    txt = xlabel('$t/s$');
    set(txt, 'Interpreter', 'latex');
    txt = ylabel('Amplitude');
    set(txt, 'Interpreter', 'latex');
    grid on

    subplot(2, 1, 2);
    stem(t0, xn);
    txt = title('Time-domain sampled signal $x(n)$');
    set(txt, 'Interpreter', 'latex');
    txt = ylabel('Amplitude');
    set(txt, 'Interpreter', 'latex');
    txt = xlabel('$t/s$');
    set(txt, 'Interpreter', 'latex');
    grid on
end
function DFTAnalysis(xn, fs)
% Function Description:
%       This function calculates the DFT[x(n)] and do spectral analysis.
% Inputs:
%       xn: digital discrete signal
%       fs: sampling frequency
% Outputs:
%       No return

    N = length(xn);    % number of sampling points
    df = fs / N;       % spectral resolution
    f = (0:N-1)*df;    % tranverse to the frequncy sequence

    % DFT using FFT algorithm
    Xk = fft(xn, N);   
    % Tranverse to the real amplitude
    RM = 2*abs(Xk)/N;

    % Amplitude-Frequency Characteristics
    figure;
    subplot(3,1,1);
    stem(f, RM,'.');
    txt = title('Amplitude-Frequency Characteristics');
    set(txt, 'Interpreter', 'latex');
    txt = xlabel('$f$/Hz');
    set(txt, 'Interpreter', 'latex');
    txt = ylabel('Amplitude');
    set(txt, 'Interpreter', 'latex');
    grid on;

    % Outline of Amplitude-Frequency Characteristics
    subplot(3,1,2);
    plot(f, RM);
    txt = title('Outline of Amplitude-Frequency Characteristics');
    set(txt, 'Interpreter', 'latex');
    txt = xlabel('$f$/Hz');
    set(txt, 'Interpreter', 'latex');
    txt = ylabel('Amplitude');
    set(txt, 'Interpreter', 'latex');
    grid on;

    % Phase-Frequency Characteristics
    subplot(3,1,3);
    stem(f, angle(Xk),'.'); 
    line([(N-1)*df, 0],[0,0]);
    txt = title('Phase-Frequency Characteristics');
    set(txt, 'Interpreter', 'latex');
    txt = xlabel('$f$/Hz');
    set(txt, 'Interpreter', 'latex');
    txt = ylabel('Phase');
    set(txt, 'Interpreter', 'latex');
    grid on;
end

Contributors

标签:Hz,fs,Based,Signal,Processing,sampling,frequency,txt,signal
From: https://www.cnblogs.com/MarkStiff/p/17798637.html

相关文章

  • 论文阅读:DeepKE:A Deep Learning Based Knowledge Extraction Toolkit for Knowledge B
    DeepKE,支持数据集和模型的结合来实现非结构化数据中信息的提取。同时提出框架和一系列的组件来实现足够的模块化和可扩展性。项目地址1.Introduction现存的KB是在实体和关系方面是不完备的。常见的一些标志性的应用:Spacy(实体识别)OpenNER(关系提取)OpenIE(信息提取)RESIN(事......
  • Transformer-based Encoder-Decoder Models
    整理原链接内容方便阅读https://colab.research.google.com/github/patrickvonplaten/notebooks/blob/master/Encoder_Decoder_Model.ipynbtitle:"Transformer-basedEncoder-DecoderModels"thumbnail:/blog/assets/05_encoder_decoder/thumbnail.pngauthors:user:p......
  • dpkg: error processing package *** (--configure)错误解决办法
    问题记录dpkg:errorprocessingpackage***(--configure)错误解决办法https://blog.csdn.net/dou3516/article/details/1051202211.sudomv/var/lib/dpkg/info//var/lib/dpkg/info_old/2.sudomkdir/var/lib/dpkg/info/3.sudoaptupdate......
  • Scikit-learn 的 preprocessing.LabelEncoder函数:标签编码
    参考文档:https://pythonjishu.com/sklearn-preprocessing-labelencoder/ 转换类别数据为整数:LabelEncoder可以将字符串或其他类别型数据转换为整数。例如,如果你有一个特征包含类别"红色"、"绿色"和"蓝色",LabelEncoder可以将它们分别编码为0、1和2。最开始我把他做向量......
  • Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round)
    \(D.EffectsofAntiPimples\)对每个数字能到达的所有位置先预处理最大值,那么就代表选择这个数字之后真实的贡献,那么对这样的预处理值,最小值显然只有一种做法,为\(2^0\),第二小的值应该可以与最小值一起选择,所以答案为\(2^1\),以此类推之后,每个值乘上对应的2的幂次之后求和即......
  • Paper Reading: Sample and feature selecting based ensemble learning for imbalanc
    目录研究动机文章贡献本文方法基于聚类的分层随机欠采样特征选择样本和特征选择的集成学习基于随机森林的SFSHEL实验结果数据集和实验设置KEEL数据集的比较HeartFailure数据集的比较优点和创新点PaperReading是从个人角度进行的一些总结分享,受到个人关注点的侧重和实力所限......
  • Signals and systems(1)
    LEC1IntroductionSignalsContinuoussignalsEX1.Soundsignals\(y=x(t)\)ContinuousTimesignal()Onedimensionsignal(onlyhaveonevariabletime)EX2.Images\(b=f(x,y)\)TwodimensionalsignalContinuoussignal(non-Timevariable)Dis......
  • Signalr断线重连机制
    前言Signalr即时消息发布到服务器后发现链接老是自动断开,导致无法发送广播后面百度搜了一下,signalr有个超时的机制 解决办法(js)//链接到自己的hub var connection = new signalR.HubConnectionBuilder().withUrl("/SignalR/chatHub").build();  //重连方法con......
  • GRLSTM:基于图的残差LSTM轨迹相似性计算《GRLSTM: Trajectory Similarity Computation
    2023年10月18日,14:14。来不及了,这一篇还是看的翻译。论文:GRLSTM:TrajectorySimilarityComputationwithGraph-BasedResidualLSTM(需要工具才能访问)Github: AAAI2023的论文。 摘要轨迹相似性的计算是许多空间数据分析应用中的一项关键任务。然而,现有的方法主要是......
  • 在Matplotlib中使用多线程multiprocessing举例
    在Matplotlib中使用多线程Matplotlib提供了一些机制来支持多线程的使用,比如使用matplotlib.pyplot.switch_backend()方法指定可用的图形后端或使用matplotlib.figure.Figure对象的canvas属性来实现绘图。但是,这些机制都需要特别小心地管理和控制,否则会引发线程之间的数据竞争和访......