fft radar velocity algorithm
10 views (last 30 days)
Show older comments
Hi,
I'm going to solve a problem related to measurement of velocity of CW radar,
after getting fft of the signal, for the time array, I have M*Tp, in which the M is the number of sweeps. So How can I extract the time and frequency from the audio signal?
it's my code:
[y,Fs] = audioread(filename);
Tp = 0.1:1;
fc = 2.43e9;
c = 3e8;
y = y(:,1);
X = fft(y);
X = X - mean(X);
f = linespace(0,Fs/2,length(y));
X = 20*log10(abs(X(1:length(y)/2+1)));
1 Comment
Vedant
on 12 Sep 2023
You are pretty close. This can be modified to include the following lines as well:
[y, Fs] = audioread(filename);
Tp = 0.1; % Pulse duration in seconds
M = size(y, 1);
T_total = M * Tp;
y = y(:, 1);
t = linspace(0, T_total, length(y));
X = fft(y);
X = X - mean(X);
X = abs(X(1:length(y)/2+1));
X = 20*log10(X);
f = linspace(0, Fs/2, length(y)/2+1);
% Plotting the time-domain signal
subplot(2,1,1);
plot(t, y);
xlabel('Time (s)');
ylabel('Amplitude');
title('Time-domain Signal');
% Plotting the frequency-domain spectrum
subplot(2,1,2);
plot(f, X);
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
title('Frequency-domain Spectrum');
This code reads the audio signal from a file, calculates the time and frequency arrays, performs the FFT on the signal, and plots both the time-domain signal and the frequency-domain spectrum. You can add any additional analysis or processing steps after the spectrum plot as needed.
Make sure to replace `filename` with the actual path or name of your audio file. Also, adjust the pulse duration `Tp` and any other parameters according to your specific requirements.
Feel free to modify the code further based on your needs or add any additional functionality you require for your velocity measurement problem.
Answers (1)
Pooja Kumari
on 20 Sep 2023
Dear Niusha,
It is my understanding that you are facing issues with extracting time and frequency from audio signal. There are two errors in your code which are as follows:
- For the time array, you have specified M*Tp where “M” is the number of sweeps and “Tp” is the pulse width. So, “Tp” must be a value in seconds which implies pulse duration.
- You have used “linespace” which will give “Unrecognized function or variable 'linespace” error. “Linespace” should be changed with “linspace” function. You can refer below documentation for more information on linspace : https://www.mathworks.com/help/matlab/ref/linspace.html
- “linspace” function is defined for “f” in which the size of the array “f” is giving “Vectors must be the same length” error as the size of “f” and “X” is not same.
Here is the corrected code for your reference:
[y,Fs] = audioread(filename);
Tp = 0.11; % pulse duration in sec
fc = 2.43e9;
c = 3e8;
y = y(:,1);
X = fft(y); %Fourier transform of signal
X = X - mean(X);
f = linspace(0,Fs/2,length(y)/2+1); % frequency array
X = 20*log10(abs(X(1:length(y)/2+1))); % audio signal in frequency domain
M = size(y, 1); % M is the number of sweeps
T_total = M * Tp;
t = linspace(0, T_total, length(y)); %time array from audio signal
I hope the provided information helps in resolving the errors you are encountering.
0 Comments
See Also
Categories
Find more on Time-Frequency Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!