Skip to main content

Low-pass and High-pass filters in MATLAB

 

MATLAB Code

 clc;
clear all;
close all;

amplitude = 1; % Amplitude of the sine wave
frequency = 10; % Frequency of the sine wave in Hertz
duration = 1; % Duration of the signal in seconds
Fs = 10000; % Sampling frequency

% Time vector
t = 0:1/Fs:duration;

% Generate the sine wave signal
sinusoidal_signal = amplitude * sin(2*pi*frequency*t) + amplitude*2 * cos(2*pi*500*t);

% Plot the sine wave signal
figure;
plot(t, sinusoidal_signal, 'b-', 'LineWidth', 2);
title('Sinusoidal Signal');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;

figure()
%demdulated
d=sinusoidal_signal;
filter=fir1(200, 10/(Fs/2), 'low');
original_t_signal=conv(filter,d);
t1=0:1/(length(original_t_signal)-1):1;
plot(t1,original_t_signal);
title('demodulated signal');

Output 

 

 
Fig: sin(2*pi*10*t) + 2cos(2*pi*500*t)
 
 
 

After Applying a Low-Pass filter which cut-off frequency is 10Hz, 

we get this 

 
 
Fig:  sin(2*pi*10*t)

 
 

MATLAB Code for High-Pass Filter

% Define or generate a sample signal
Fs = 1000; % Sampling frequency
t = 0:1/Fs:1; % Time vector
f_signal = 50; % Frequency of the signal
signal = sin(2*pi*f_signal*t);

% Design a high-pass filter
cutoff_frequency = 10; % Cutoff frequency in Hz
filter_order = 200; % Filter order
highpass_filter = fir1(filter_order, cutoff_frequency/(Fs/2), 'high');

% Apply the high-pass filter to the signal
filtered_signal = filter(highpass_filter, 1, signal);

% Plot the original and filtered signals
figure;
subplot(2,1,1);
plot(t, signal);
title('Original Signal');
xlabel('Time');
ylabel('Amplitude');

subplot(2,1,2);
plot(t, filtered_signal);
title('High-pass Filtered Signal');
xlabel('Time');
ylabel('Amplitude');

% Add a legend
legend('Original Signal', 'Filtered Signal');

% Show the plot
grid on;
 

Output (when cut-off frequency is 10 Hz and original signal is set to 50 Hz)

 
 

Output (when cut-off frequency is 60 Hz and original signal is set to 50 Hz)

 
 
 

Copy the MATLAB Code from here

For Low-pass filter

 

 

For High-pass filter

 

People are good at skipping over material they already know!

View Related Topics to







Contact Us

Name

Email *

Message *

Popular Posts

Online Simulator for ASK, FSK, and PSK

Try our new Digital Signal Processing Simulator!   Start Simulator for binary ASK Modulation Message Bits (e.g. 1,0,1,0) Carrier Frequency (Hz) Sampling Frequency (Hz) Run Simulation Simulator for binary FSK Modulation Input Bits (e.g. 1,0,1,0) Freq for '1' (Hz) Freq for '0' (Hz) Sampling Rate (Hz) Visualize FSK Signal Simulator for BPSK Modulation ...

Constellation Diagrams of ASK, PSK, and FSK

📘 Overview of Energy per Bit (Eb / N0) 🧮 Online Simulator for constellation diagrams of ASK, FSK, and PSK 🧮 Theory behind Constellation Diagrams of ASK, FSK, and PSK 🧮 MATLAB Codes for Constellation Diagrams of ASK, FSK, and PSK 📚 Further Reading 📂 Other Topics on Constellation Diagrams of ASK, PSK, and FSK ... 🧮 Simulator for constellation diagrams of m-ary PSK 🧮 Simulator for constellation diagrams of m-ary QAM BASK (Binary ASK) Modulation: Transmits one of two signals: 0 or -√Eb, where Eb​ is the energy per bit. These signals represent binary 0 and 1.    BFSK (Binary FSK) Modulation: Transmits one of two signals: +√Eb​ ( On the y-axis, the phase shift of 90 degrees with respect to the x-axis, which is also termed phase offset ) or √Eb (on x-axis), where Eb​ is the energy per bit. These signals represent binary 0 and 1.  BPSK (Binary PSK) Modulation: Transmits one of two signals...

BER vs SNR for M-ary QAM, M-ary PSK, QPSK, BPSK, ...

📘 Overview of BER and SNR 🧮 Online Simulator for BER calculation of m-ary QAM and m-ary PSK 🧮 MATLAB Code for BER calculation of M-ary QAM, M-ary PSK, QPSK, BPSK, ... 📚 Further Reading 📂 View Other Topics on M-ary QAM, M-ary PSK, QPSK ... 🧮 Online Simulator for Constellation Diagram of m-ary QAM 🧮 Online Simulator for Constellation Diagram of m-ary PSK 🧮 MATLAB Code for BER calculation of ASK, FSK, and PSK 🧮 MATLAB Code for BER calculation of Alamouti Scheme 🧮 Different approaches to calculate BER vs SNR What is Bit Error Rate (BER)? The abbreviation BER stands for Bit Error Rate, which indicates how many corrupted bits are received (after the demodulation process) compared to the total number of bits sent in a communication process. BER = (number of bits received in error) / (total number of tran...

MATLAB Code for Rms Delay Spread

RMS delay spread is crucial when you need to know how much the signal is dispersed in time due to multipath propagation, the spread (variance) around the average. In high-data-rate systems like LTE, 5G, or Wi-Fi, even small time dispersions can cause ISI. RMS delay spread is directly related to the amount of ISI in such systems. RMS Delay Spread [↗] Delay Spread Calculator Enter delays (ns) separated by commas: Enter powers (dB) separated by commas: Calculate   The above calculator Converts Power to Linear Scale: It correctly converts the power values from decibels (dB) to a linear scale. Calculates Mean Delay: It accurately computes the mean excess delay, which is the first moment of the power delay profile. Calculates RMS Delay Spread: It correctly calculates the RMS delay spread, defined as the square root of the second central moment of the power delay profile.   MATLAB Code  clc...

LDPC Encoding and Decoding Techniques

📘 Overview & Theory 🧮 LDPC Encoding Techniques 🧮 LDPC Decoding Techniques 📚 Further Reading 'LDPC' is the abbreviation for 'low density parity check'. LDPC code H matrix contains very few amount of 1's and mostly zeroes. LDPC codes are error correcting code. Using LDPC codes, channel capacities that are close to the theoretical Shannon limit can be achieved.  Low density parity check (LDPC) codes are linear error-correcting block code suitable for error correction in a large block sizes transmitted via very noisy channel. Applications requiring highly reliable information transport over bandwidth restrictions in the presence of noise are increasingly using LDPC codes. 1. LDPC Encoding Technique The proper form of H matrix is derived from the given matrix by doing multiple row operations as shown above. In the above, H is parity check matrix and G is generator matrix. If you consider matrix H as [-P' | I] then matrix G will be...

Comparisons among ASK, PSK, and FSK | And the definitions of each

📘 Comparisons among ASK, FSK, and PSK 🧮 Online Simulator for calculating Bandwidth of ASK, FSK, and PSK 🧮 MATLAB Code for BER vs. SNR Analysis of ASK, FSK, and PSK 📚 Further Reading 📂 View Other Topics on Comparisons among ASK, PSK, and FSK ... 🧮 Comparisons of Noise Sensitivity, Bandwidth, Complexity, etc. 🧮 MATLAB Code for Constellation Diagrams of ASK, FSK, and PSK 🧮 Online Simulator for ASK, FSK, and PSK Generation 🧮 Online Simulator for ASK, FSK, and PSK Constellation 🧮 Some Questions and Answers Modulation ASK, FSK & PSK Constellation MATLAB Simulink MATLAB Code Comparisons among ASK, PSK, and FSK    Comparisons among ASK, PSK, and FSK Comparison among ASK, FSK, and PSK Parameters ASK FSK PSK Variable Characteristics Amplitude Frequency ...

What is a Chirp Signal?

📘 Overview & Theory 🧮 MATLAB Code 📚 Further Reading   Chirp signals are often used to find target objects. In a chirp signal, the frequency varies with time. For up-chirp signals, frequency increases with time. Oppositely, for down-chirp signals, the frequency decreases with time. Advantages of a chirp signal over a single-toned signal Better resolution Better Security The wide bandwidth of a chirp signal allows for capturing more detailed info about the target or object In a chirp signal, pulse compression enhances resolution by concentrating the signal energy into a shorter duration of time It is less susceptible to noise  It improves signal to noise ratio Up-Chirp Signal A sinusoidal up-chirp signal is denoted as Where A is the amplitude of this signal             f0 is the starting frequency of the chirp at t=0             Î± is the chirp rate or the rate at which the frequency incre...

What are the main lobe and side lobes in Beamforming

    What are the main lobe and side lobes in Beamforming? You've probably noticed that in the diagram of  beamforming , there are two types of lobes in beamforming patterns. One is the main lobe, while the others are side lobes. We intend to communicate with receivers with a stronger directional path from the transmitter when we produce beams for wireless communication. We can also see side lobes in this scenario. These side lobes, on the other hand, are not necessary for effective communication. As a result, we take various procedures to remove those side lobes or to reduce the number of side lobes as much as feasible; otherwise, inter-symbol interference  occurs, and signal quality suffers. Figure: Illustration of Main Lobe and Side lobes, where the x-axis denotes the angle of arrival (AOA) and angle of departure (AOD), respectively, while, the y-axis denotes the gain/power in dB (decibel).     In the case of MIMO antennas, our major goal is to reduce int...