I want to code and plot for time-frequency analysis using Fourier transform. I do not know how can I code them and plotting.
1 次查看（过去 30 天）
I have given A-scan (amplitudes) data for six stages for the ultrasonic signals. So, I have normalised the amplitudes data for six stages. Then plotted time vs normalised amplitude. Now, I do not understand how can code for frequency response using FFT and plot frequency(KHz) vs magnitude. I am going to wring my normalised code underneath.
clear; close all; clc;
data_file = "Q2.xlsx"
u = readmatrix(data_file);
fs = 2.25e6; %in hz
N = size(u,1);
t = (0:(N-1))*fs;
normalised_amplitude = zeroes(size(u));
for i = 1:size(U,2)
ui = u(:,i);
ui = ui/max(abs(ui)); %normalisation of signal
normalised_amplitude(:,i) = ui;
Nithin Kumar 2023-8-30
编辑：Nithin Kumar 2023-8-30
I understand that you have normalized the A-scan amplitudes data for six stages and want to know the Implementation of frequency response using FFT and plot frequency vs magnitude graph.
To calculate the frequency response using FFT, kindly refer to the following steps:
1. Calculate FFT: Use “fft” function to calculate the Fast Fourier Transform of your normalized A-scan data for each of the six stages.
N = length(normalized_data); % Length of the data
fft_result = fft(normalized_data);
2. Frequency Axis: Create a frequency axis using the sampling rate and the length of your data.
fs = sampling_rate; % Replace with your actual sampling rate
f = fs*(0:(N/2))/N;
3. Magnitude Calculation: Calculate the magnitude of the FFT result.
magnitude = abs(fft_result(1:N/2+1));
4. Plotting: Plot the frequency vs magnitude:
title('Frequency Response using FFT');
Combine the above steps with your normalized A-scan data for each stage and set the desired sampling rate value.
To know more information regarding the frequency analysis using FFT, kindly refer to the following documentation.
I hope this answer helps you.