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

How to Plot a FFT Plot of a Signal in MATLAB

 

MATLAB Code 

clc;
clear all;
close all;
fs = 1000; % Sampling frequency
dt = 1/fs; % Sampling period
L = 1500; % Length of signal

t=( (0:L-1)-ceil((L-1)/2) )*dt ; % Time vector

x = 0.7*sin(2*pi*400*t);

[X,freq]=continuousFTsamples(x,dt);

tiledlayout(1,2)
nexttile
plot(t,x); axis square; xlabel 'Time (sec)'; ylabel 'x(t)'
nexttile
plot(freq,abs(X)); axis square; xlabel 'Freq. (Hz)'; ylabel 'X(f)')

function [X,freq]=continuousFTsamples(x,dt,varargin)

X=fftshift( fft( ifftshift(x), varargin{:} ) )*dt;

L=numel(X);

df=1/L/dt;

freq=( (0:L-1)-ceil((L-1)/2) )*df;

end
 

Output

 


How long will the above process will work properly

 Restrictions

As here sampling frequency is equal to 1000. So the highest frequency available in the message signal must be equal or below half of the sampling frequency.
 

 If the frequency of the message signal is equal to 499 (half of sampling frequency = 500 Hz)

 
If the frequency of the message signal is equal to 500 (half of the sampling frequency = 500 Hz)
 

If the frequency of the message signal is equal to 1000 (when half of the sampling frequency = 500 Hz)


 Copy the above MATLAB Code from Here

 

People are good at skipping over material they already know!

View Related Topics to

How to Plot a FFT Plot of a Signal in MATLAB







CATEGORY LIST :

  1. Modulation
  2. Signal Processing
  3. MATLAB
  4. Beamforming
  5. 5G
  6. Wireless
  7. Channel Impulse Response
  8. Fourier Transform
  9. MIMO - Multiple Input Multiple Output
  10. ASK FSK PSK
  11. Constellation Diagrams
  12. GATE-ESE-NET
  13. Programming
  14. Telecommunication
  15. Computer Networks
  16. Filters
  17. Fourier Series and Fourier Transform
  18. Millimeter wave
  19. Pulse Modulation
  20. Python
  21. BER vs SNR
  22. Equalizers
  23. Applications and Games
  24. Electronics Industry
  25. Frequency bands
  26. Gaussian Random Variable
  27. QAM
  28. Spectral density estimation
  29. Wireless Communication Q & A
  30. Channel Model
  31. Convolution
  32. Image Processing
  33. IoTs
  34. Singular Value Decomposition (SVD)
  35. UWB
  36. pskmod
  37. Antenna
  38. C Programming
  39. Channel Estimation
  40. Projects
  41. Q & A
  42. Rayleigh Fading
  43. Transform
  44. Alamouti's Scheme
  45. Fading
  46. Microwave
  47. News about 5G
  48. OFDM
  49. PAM
  50. PCM
  51. Python Matrix Operations
  52. SSC Exam
  53. Web Design
  54. WordPress
  55. Ionospheric Communication
  56. JavaScript
  57. MATLAB Simulink
  58. Mobile & Accessories
  59. Signal Processing for 5G
  60. Analog Circuits
  61. Cell Towers
  62. Computer
  63. Digital Circuits
  64. Fourier Series
  65. HomePage
  66. Information and Coding Theory
  67. Laplace Transform
  68. MySQL
  69. Node.js
  70. Search
  71. ShareLinkF
  72. Z Transform

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

Channel Estimation utilizing Decision Feedback Equalizer (DFE)

  Channel estimation using DFE is a similar process to a non-linear equalization process. In DFE (decision feed equalizer), equalization error bits/symbols between the feedforward tabs and feedback taps are calculated continuously. And equalizer's tap weights tap weights are updated correspondingly.  In plain language, the error between the received bits and known training bits is calculated, and tap weights are updated accordingly. The equalizer estimates the channel impulse response (CIR) .  Once we find the channel impulse response or channel information, we can easily retrieve the original message signal from the noisy data. In the communication process, the whole system is modeled as a linear time-invariant (LTI) system. And  y = h*x + n where, y = received signal            x = transmitted signal           n = additive white Gaussian noise [Read more about the Linear time-invariant (LTI) system and convolu...

MATLAB code for GMSK

  Copy the MATLAB code from here  % The code is developed by SalimWireless.com clc; clear; close all; % Parameters samples_per_bit = 36; bit_duration = 1; num_bits = 20; sample_interval = bit_duration / samples_per_bit; time_vector = 0:sample_interval:(num_bits * bit_duration); time_vector(end) = []; % Generate and modulate binary data binary_data = randi([0, 1], 1, num_bits); modulated_bits = 2 * binary_data - 1; upsampled_signal = kron(modulated_bits, ones(1, samples_per_bit)); figure; plot(time_vector, upsampled_signal); title('Message Signal'); % Apply Gaussian filter filtered_signal = conv(GMSK_gaussian_filter1(bit_duration, samples_per_bit), upsampled_signal); filtered_signal = [filtered_signal, filtered_signal(end)]; figure; plot(filtered_signal); title('Filtered Signal'); % Integration & GMSK modulation integrated_signal = cumsum(filtered_signal); gmsk_signal = exp(1i * integrated_signal); % Plotting the real and imaginary parts of the GMSK signal ...

Difference between AWGN and Rayleigh Fading

Wireless Signal Processing Gaussian and Rayleigh Distribution Difference between AWGN and Rayleigh Fading 1. Introduction Rayleigh fading coefficients and AWGN, or additive white gaussian noise [↗] , are two distinct factors that affect a wireless communication channel. In mathematics, we can express it in that way.  Fig: Rayleigh Fading due to multi-paths Let's explore wireless communication under two common noise scenarios: AWGN (Additive White Gaussian Noise) and Rayleigh fading. y = h*x + n ... (i) Symbol '*' represents convolution. The transmitted signal  x  is multiplied by the channel coefficient or channel impulse response (h)  in the equation above, and the symbol  "n"  stands for the white Gaussian noise that is added to the signal through any type of channel (here, it is a wireless channel or wireless medium). Due to multi-paths the channel impulse response (h) changes. And multi-paths cause Rayleigh fa...

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...

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,...

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...

BER vs SNR for ASK, FSK, and PSK

  BER vs. SNR denotes how many bits in error are received in a communication process for a particular Signal-to-noise (SNR) ratio. In most cases, SNR is measured in decibel (dB). For a typical communication system, a signal is often affected by two types of noises 1. Additive White Gaussian Noise (AWGN) 2. Rayleigh Fading In the case of additive white Gaussian noise (AWGN), random magnitude is added to the transmitted signal. On the other hand, Rayleigh fading (due to multipath) attenuates the different frequency components of a signal differently. A good signal-to-noise ratio tries to mitigate the effect of noise.  Calculate BER for Binary ASK Modulation The theoretical BER for binary ASK (BASK) in an AWGN channel is given by: BER  = (1/2) * erfc(0.5 * sqrt(SNR_ask));   Enter SNR (dB): Calculate BER BER vs. SNR curves for ASK, FSK, and PSK Calculate BER for Binary FSK Modulation The theoretical BER for binary FSK (BFSK) in a...

Calculation of SNR from FFT bins in MATLAB

  Here, you can find the SNR of a received signal from periodogram / FFT bins using the Kaiser operator. The beta (β) parameter characterizes the Kaiser window, which controls the trade-off between the main lobe width and the side lobe level in the frequency domain. For that you should know the sampling rate of the signal.  The Kaiser window is a type of window function commonly used in signal processing, particularly for designing finite impulse response (FIR) filters and performing spectral analysis. It is a general-purpose window that allows for control over the trade-off between the main lobe width (frequency resolution) and side lobe levels (suppression of spectral leakage). The Kaiser window is defined using a modified Bessel function of the first kind.    Steps Set up the sampling rate and time vector Compute the FFT and periodogram Plot the periodogram using FFT Specify parameters for Kaiser window and periodogram Calculate the frequency resolution and signal...