[Matlab] Algorithm Craftsman video 1: Digital signal processing simulation and realization the first signal source generation and filtering 1, 2

Source: Internet
Author: User
Tags sin

Need to cooperate with teaching video to eat:

% Cheerful Version

https://www.bilibili.com/video/av17343551

https://www.bilibili.com/video/av17707835

% Serious version

https://www.bilibili.com/video/av16683579

Course-Related code:

The generation and filtering of the 1% firdesign.m% author: the author of the copy is the UP master.  % June 3, 2018 18:12:35clear; Close all;clc;fc1 = 10;FC2 = 100;FC3 = 450;      % of three frequency components FS = 1000; % Sample Frequency point_s = 1000;   % Sample point time = [1:point_s]/fs;    % time domain sampling temporal variable delta_f = 1*fs/point_s; % Frequency Resolution SIN_S1 = 0.5*sin (2*pi*fc1*time); sin_s2 = 1.1*sin (2*pi*fc2*time); sin_s3 = 0.8*sin (2*pi*fc3*time); sin_s = Sin_s1 + Sin_s2 + sin_s3; % generation and synthesis signal fft_s1 = FFT (sin_s), figure (1), subplot (2,1,1);p lot (time,sin_s), title (' Original Time domain signal '); f = 0:point_s/2-1;f = F*delta_ F;danbianfudu = 2*abs (FFT_S1 (1:POINT_S/2)), subplot (2,1,2);p lot (F,danbianfudu), title (' Frequency domain amplitude characteristics '),%%%%%% filter processing% Design low-pass filter , the upper cutoff frequency is FC = 120hz% WC = fc/(FS/2);    N = 128; % Filter Order FC = 120;WC = fc/(FS/2); Fir1_lowpass_filter = Fir1 (N,WC); figure (2); Freqz (Fir1_lowpass_filter); % view amplitude characteristics and phase characteristics (normalized frequency) title (' 128 Order lowpass filter '),% implementation filter FILTER_SIN_S1 = filter (fir1_lowpass_filter,1,sin_s); fft_low_filter = FFT (FILTER_SIN_S1); Figure (3), subplot (2,1,1);p lot (time,filter_sin_s1), title (' Low Pass filtered time domain waveform ') subplot (2,1,2);d Anbianfudu = 2*abs (fft_low_ FIlter (1:POINT_S/2));p lot (F,danbianfudu), title (' Frequency amplitude characteristics after low pass filtering '),% filter processing% Design a high-tube filter, cutoff frequency is 15HZFC =; WC = fc/(FS/2); % Video Courseware write 0.15, because this example wc=0.15 corresponds to 75Hz can also filter out 75Hz, I take 20hzfir1_hp_filter = Fir1 (N,WC, ' High '); figure (4); FREQZ (fir1_hp _filter); filter_sin_s2 = filter (fir1_hp_filter,1,sin_s); fft_high_filter = FFT (FILTER_SIN_S2); figure (5); subplot ( 2,1,1);p lot (time,filter_sin_s2), title (' High Pass filtered time domain waveform '), subplot (2,1,2);d Anbianfudu = 2*abs (Fft_high_filter (1:point_s  /2));p lot (F,danbianfudu), title (' High-pass filtered frequency domain amplitude characteristics ');

  

Study questions: How do I implement a band-pass filter and a band-stop filter?

% bandpass filter% only let 100Hz through%WC1 = 50/(FS/2);%wc2 = 400/(FS/2); fc1 = 50;FC2 = 400;WC1 = FC1/(FS/2); WC2 = FC2/(FS/2); fir1_ba  Nd_pass_filter = Fir1 (n,[wc1 WC2], ' bandpass '); %ftype%figure (6); Freqz (fir1_band_pass_filter);% Implementation filter FIR1_BP_S1 = filter (fir1_band_pass_filter,1,sin_s); fft_bp_ Filter = FFT (FIR1_BP_S1), figure (7), subplot (2,1,1);p lot (time, fir1_bp_s1), title (' Band-pass filter post-filter waveform '); subplot (2,1,2); Danbianfudu = 2*abs (Fft_bp_filter (1:POINT_S/2));p lot (F,danbianfudu), title (' Band-pass filtered frequency amplitude characteristics '),% Band-stop filter% only 100Hz passed%WC1 = 50/(FS/2);%wc2 = 400/(FS/2); fc1 = 50;FC2 = 400;WC1 = FC1/(FS/2); WC2 = FC2/(FS/2); fir1_band_stop_filter = Fir1 (  N,[WC1 WC2], ' stop '); %ftype%figure (8); Freqz (fir1_band_stop_filter);% Implementation filter FIR1_BS_S1 = filter (fir1_band_stop_filter,1,sin_s); fft_bs_ Filter = FFT (FIR1_BS_S1), figure (9), subplot (2,1,1);p lot (time, fir1_bs_s1), title (' Band filter After filter waveform '); subplot (2,1,2); Danbianfudu = 2*abs (Fft_bs_filter (1:POINT_S/2));p lot (F,danbianfudu), title (' frequency amplitude characteristics after band-stop Filtering ');

  

[Matlab] algorithm Craftsman video 1: Digital signal processing simulation and implementation the first signal source generation and filtering 1, 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.