# Creating and recovering a frequency shift in time domain in MATLAB

• MATLAB
• tworitdash
In summary: Additionally, for the red plot, it seems like there might be an error in the code for reconstructing the original signal. Make sure to check that the phase is correctly calculated and applied in the reconstruction process. In summary, it looks like there may be errors in the code for both the modification and reconstruction processes, resulting in incorrect plots. Make sure to carefully check and correct these errors to get the desired results.
tworitdash
I am trying to simulate and process the Doppler signals. My main problem is a little more complex so I am only posting a simple version of it. Task1: I have a time-domain signal with the velocity of the target as mu. I need to change the velocity to mu cos(theta) where theta is a vector from 0 to 2 pi with the same number of points that I have in the time domain signal. So, every point in the original time-domain signal should have this change. This means that the Doppler frequency (velocity) is not constant with time. Task2: Then, after I get this signal, I want to recover the original spectrum (with constant velocity) but without knowing mu. I just need to know the phase and then modify it somehow to get the real signal.
 clear;
close all;

lambda = 0.03;
M = 61;
hs = 128;

N = hs * M; % Number of points in the time axis

mu = 4; % Doppler velocity

PRT = 1e-3;  % Time step

t1 = 0:PRT:(N - 1)*PRT; % Time axis

s_ = exp(1j .* 4 * pi ./ lambda .* mu .* t1); % Original Time domain signal

s_f = fftshift(fft(s_)); % FT of the original time domain signal

v_amb = 7.5;

v_axis = linspace(-N/2, N/2-1, N)/N .* 2 * v_amb; % Velocity axis

figure; plot(v_axis, db(abs(s_f))); title('Original spectrum') % Original spectrum
BW = 1*pi/180;
p0 = 0*pi/180;
p1 = 360*pi/180;
th = linspace(p0, p1, N); % Angle axis for cos(theta)

s_man_ = abs(s_) .* exp(1j .* (angle(s_)) + 1j * 4*pi/lambda * mu * (cos(th) - 1) .* t1); % Modified time domain signal with cos(theta)

s_man_f_full = fftshift(fft(s_man_)); % FT of the modified time domain signal

s_man_comp = abs(s_man_) .* exp(1j .* (angle(s_man_)) ./ cos(th)); % Reconstruction of the original signal in time domain

s_man_comp_f = fftshift(fft(s_man_comp)); % FT of the reconstructed signal

figure(1); hold on; plot(v_axis, db(abs(s_man_f_full)));

hold on; plot(v_axis, db(abs(s_man_comp_f)));

legend({'HD spectrum', 'Manipulated with cosine Spectrum', 'Compensated from Manipulated spectrum'});  grid on;
The figure is shown below. The Yellow plot should resemble the blue blot but it doesn't. Any idea what I do wrong here? The red plot also should show multiple spikes in the plot and not like a noise signal like this I suppose.

Delta2
It looks like you are not correctly modifying the signal with the cosine theta vector. The theta vector should be used to modify the phase of the signal, not its amplitude. Try modifying the signal with a phase shift equal to mu * (cos(theta) - 1) * t1 and see if you get the desired results.

## 1. How do I create a frequency shift in time domain in MATLAB?

To create a frequency shift in time domain in MATLAB, you can use the fft and ifft functions. First, use the fft function to convert your signal into the frequency domain. Then, multiply the frequency domain signal by a complex exponential with the desired frequency shift. Finally, use the ifft function to convert the signal back to the time domain.

## 2. Can I recover the original signal after applying a frequency shift in time domain?

Yes, you can recover the original signal by using the inverse of the frequency shift process. First, apply the inverse frequency shift by multiplying the frequency domain signal by a complex exponential with the negative of the desired frequency shift. Then, use the ifft function to convert the signal back to the time domain.

## 3. How do I specify the frequency shift in MATLAB?

To specify the frequency shift in MATLAB, you can use the fs parameter in the fft function. This parameter represents the sampling frequency of the input signal and is used to determine the frequency range of the output signal. By changing the fs value, you can effectively shift the frequency of the output signal.

## 4. Can I apply a frequency shift to a specific frequency range?

Yes, you can apply a frequency shift to a specific frequency range by first using the fft function to convert the signal into the frequency domain. Then, you can manipulate the frequency domain signal by multiplying the desired frequency range by a complex exponential with the desired frequency shift. Finally, use the ifft function to convert the signal back to the time domain.

## 5. Are there any other methods for creating and recovering a frequency shift in time domain in MATLAB?

Yes, in addition to using the fft and ifft functions, you can also use the fftshift and ifftshift functions to create and recover a frequency shift in time domain in MATLAB. These functions shift the frequency range of the signal before and after the fft and ifft operations, respectively.

Replies
1
Views
994
Replies
10
Views
2K
Replies
13
Views
2K
Replies
8
Views
2K
Replies
5
Views
2K
Replies
16
Views
14K
Replies
17
Views
1K
Replies
14
Views
6K
Replies
4
Views
5K
Replies
3
Views
2K