Skip to main content
Home Wireless Communication Modulation MATLAB Beamforming Project Ideas MIMO Computer Networks Lab 🚀

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







Admin & Author: Salim

profile

  Website: www.salimwireless.com
  Interests: Signal Processing, Telecommunication, 5G Technology, Present & Future Wireless Technologies, Digital Signal Processing, Computer Networks, Millimeter Wave Band Channel, Web Development
  Seeking an opportunity in the Teaching or Electronics & Telecommunication domains.
  Possess M.Tech in Electronic Communication Systems.


Contact Us

Name

Email *

Message *

Popular Posts

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

Modulation Constellation Diagrams BER vs. SNR BER vs SNR for M-QAM, M-PSK, QPSk, BPSK, ... 1. 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. It is defined as,  In mathematics, BER = (number of bits received in error / total number of transmitted bits)  On the other hand, SNR refers to the signal-to-noise power ratio. For ease of calculation, we commonly convert it to dB or decibels.   2. What is Signal the signal-to-noise ratio (SNR)? SNR = signal power/noise power (SNR is a ratio of signal power to noise power) SNR (in dB) = 10*log(signal power / noise power) [base 10] For instance, the SNR for a given communication system is 3dB. So, SNR (in ratio) = 10^{SNR (in dB) / 10} = 2 Therefore, in this instance,...

Constellation Diagrams of ASK, PSK, and FSK

Modulation ASK, FSK & PSK Constellation 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: +√Eb​ or -√Eb (they differ by 180 degree phase shift), where Eb​ is the energy per bit. These signals represent binary 0 and 1.  This article will primarily discuss constellation diagrams, as well as what constellation diagrams tell us and the significance of constellation diagrams. Constellation diagrams can often demonstrate how the amplitude and phase of signals or symbols differ. These two characteristics lessen the interference between t...

MATLAB code for BER vs SNR for M-QAM, M-PSK, QPSk, BPSK, ...

Modulation Constellation Diagrams BER vs. SNR MATLAB code for BER vs SNR for M-QAM, M-PSK, QPSk, BPSK, ...   MATLAB Script for  BER vs. SNR for M-QAM, M-PSK, QPSk, BPSK %Written by Salim Wireless %Visit www.salimwireless.com for study materials on wireless communication %or, if you want to learn how to code in MATLAB clc; clear; close all; % Parameters num_symbols = 1e5; % Number of symbols snr_db = -20:2:20; % Range of SNR values in dB % PSK orders to be tested psk_orders = [2, 4, 8, 16, 32]; % QAM orders to be tested qam_orders = [4, 16, 64, 256]; % Initialize BER arrays ber_psk_results = zeros(length(psk_orders), length(snr_db)); ber_qam_results = zeros(length(qam_orders), length(snr_db)); % BER calculation for each PSK order and SNR value for i = 1:length(psk_orders) psk_order = psk_orders(i); for j = 1:length(snr_db) % Generate random symbols data_symbols = randi([0, psk...

Constellation Diagram of FSK in Detail

  Binary bits '0' and '1' can be mapped to 'j' and '1' to '1', respectively, for Baseband Binary Frequency Shift Keying (BFSK) . Signals are in phase here. These bits can be mapped into baseband representation for a number of uses, including power spectral density (PSD) calculations. For passband BFSK transmission, we can modulate signal 'j' with a lower carrier frequency and signal '1' with a higher carrier frequency while transmitting over a wireless channel. Let's assume we are transmitting carrier signal fc1 for the transmission of binary bit '1' and carrier signal fc2 for the transmission of binary bit '0'. Energy per bit (Eb): (For transmission of binary ‘1’) (For transmission of binary ‘0’) Constellation Diagram of FSK Fig 1: Constellation Diagram of FSK  In the above figure values are in terms of the normalized functions. √(2/Tb).cos2Пf1t and √(2/Tb).cos2Пf2t are orthogonal functions in the inter...

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

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 Performance Comparison: 1. Noise Sensitivity:    - ASK is the most sensitive to noise due to its reliance on amplitude variations.    - PSK is less sensitive to noise compared to ASK.    - FSK is relatively more robust against noise, making it suitable for noisy environments. 2. Bandwidth Efficiency:    - PSK is the most bandwidth-efficient, requiring less bandwidth than FSK for the same data rate.    - FSK requires wider bandwidth compared to PSK.    - ASK's bandwidth efficiency lies between FSK and PSK. Bandwidth Calculator for ASK, FSK, and PSK The baud rate represents the number of symbols transmitted per second Select Modulation Type: ASK...

Simulation of ASK, FSK, and PSK using MATLAB Simulink

ASK, FSK & PSK HomePage MATLAB Simulation Simulation of Amplitude Shift Keying (ASK) using MATLAB Simulink      In Simulink, we pick different components/elements from MATLAB Simulink Library. Then we connect the components and perform a particular operation.  Result A sine wave source, a pulse generator, a product block, a mux, and a scope are shown in the diagram above. The pulse generator generates the '1' and '0' bit sequences. Sine wave sources produce a specific amplitude and frequency. The scope displays the modulated signal as well as the original bit sequence created by the pulse generator. Mux is a tool for displaying both modulated and unmodulated signals at the same time. The result section shows that binary '1' is modulated by a certain sine wave amplitude of 1 Volt, and binary '0' is modulated by zero amplitude. Simulation of Frequency Shift Keying (FSK) using MATLAB Simulink   Result The diagram above shows t...

Frequency Bands : EHF, SHF, UHF, VHF, HF, MF, LF, VLF and Their Uses

Frequency Bands EHF, SHF, UHF, VHF, HF, MF, LF... 1. Extremely High Frequency (EHF)30 - 300 GHz Uses 5G Networks 5G millimeter wave band , 6G and beyond (Experimental) RADAR, 2. Super High Frequency (SHF)3 - 30 GHz Uses Ultra-wideband (UWB , Airborne RADAR, Satellite Communication, Microwave Link Communication or SATCOM 3. Ultra High Frequency (UHF)300 - 3000 MHz Uses Satellite Communication, Television, surveillance, navigation aids Also, read important wireless communication terms 4. Very High Frequency (VHF)30 - 300 MHz Uses Television, FM broadcast, navigation aids, air traffic control, 5. High Frequency (HF)3 - 30 MHz Uses Telephone, Telegram and Facsimile, ship to coast, ship to aircraft communication, amateur radio, 6. Medium Frequency (MF)300 - 3000 KHz Uses coast guard communication, direction finding, AM broadcasting , maritime radio, 7. Low Frequency (LF)30 - 300 KHz Uses Radio beacons, Navigational Aids 8. Very Low Frequency (VLF)3 - 30 KHz...

Raised Cosine Filter in MATLAB

  MATLAB Code clc; clear all; close all; Data_sym = [0 1 1 0 1 0 0 1]; M = 4; Phase = 0; Sampling_rate = 48e3; Data_Rate = 100; Bandwidth = 400; Upsampling_factor = Sampling_rate/Data_Rate; Rolloff = 0.4; Upsampled_Data = upsample(pskmod(Data_sym,M,Phase),Upsampling_factor); Pulse_shape = firrcos(2*Upsampling_factor,Bandwidth/2,Rolloff,Sampling_rate,'rolloff','sqrt'); Output What if we change the roll-off roll-off = 0.01 roll-off = 0.99 What if we change the bandwidth Bandwidth = 100 Hz     Bandwidth = 1000 Hz    What if we change the sampling rate  Sampling rate = 10 KHz  Sampling rate = 100 KHz Another MATLAB Code % The code is developed by SalimWireless.Com clc; clear; close all; % Parameters fs = 1000; % Sampling frequency in Hz symbolRate = 100; % Symbol rate (baud) span = 6; % Filter span in symbols alpha = 0.25; % Roll-off factor for raised cosine filter % Generate random data symbols numSymbols = 100; % Number of symbols data = randi([0 1], num...