Filter löschen
Filter löschen

fft radar velocity algorithm

15 Ansichten (letzte 30 Tage)
Niusha
Niusha am 12 Sep. 2023
Beantwortet: Pooja Kumari am 20 Sep. 2023
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 Kommentar
Vedant
Vedant am 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Pooja Kumari
Pooja Kumari am 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:
  1. 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.
  2. You have used “linespace” which will giveUnrecognized 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
  3. “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.

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by