# How to put specific frequency in a specific bin in frequency domain?

I have eight tones as represented by f, and I want to the distance between every two tones is different as shown in the figure, I have the frequency spacing, but I need to put the tones properly, and I need the resolution and the number of samples to be suitable for FFT consideration.

N=8;
r=1;
f_d=1e3;
M=4;
m=0:M-1;
fc=2.45e9;
%% freq spacing
for j=1:M
f_spac(j)=(1+m(j)*r)*f_d;      %freq spacing
end
%% Generate the frequency vector
for i=1:M
f(:,i)=[fc+((1+m(i)*r)/2)*f_d; fc-((1+m(i)*r)/2)*f_d];
end
B = reshape(f,[1,N]);
fs=20*f(N/2); % Sampling frequency
Ts=1/fs; % Sampling time
t=0:Ts:1e3*Ts; % Time vector


I ran your code, there were some errors. f_spac variable is not used after it is filled inside the for-loop. What you can do is to define a variable f_delta=1000. This will make sure the 'f' variable is filled properly with spacing of 1000 and its multiples.

N=8;
r=1;
f_d=1e3;
M=4;
m=0:M-1;
fc=0;
%% freq spacing
for j=1:M
f_spac(j)=(1+m(j)*r)*f_d;      %freq spacing
end
f_delta = 1000;
%% Generate the frequency vector
for i=1:M
f(:,i)=[fc+((1+m(i)*r)/2)*f_delta; fc-((1+m(i)*r)/2)*f_delta];
end
B = reshape(f,[1,N]);
fs=20*f(N/2); % Sampling frequency
Ts=1/fs; % Sampling time
t=0:Ts:1e3*Ts; % Time vector


At the bare minimum, you need FFT size to be 8 with Fs = 4kHz. But before that you need to down-convert the signal to baseband.

• I edited my code, sorry for that, for the baseband signal I will get it through the intermodulation, after FFT, but I need to put the tones in a specific distance. my question is how to put the tones in specific bins to get the multiples of 1000. Fs >= 2f(N/2). Thanks @jithin Mar 13, 2020 at 4:37
• I am not sure if I understood when you say "put the tones in specific bins". That is not how FFT works. If you want the FFT values to reflect the tone values, you need to choose resolution frequencies (Fs/N) corresponding position of tones. As I mentioned above if your Fs=4kHz, N=8, f_spacing=500Hz. For bin 1 and bin -1, you get the 2 tones that are 1000Hz apart. For bin 2 and bin -2, you get the 2 tones that 4*500=2000Hz apart..Hope you understood. Mar 13, 2020 at 7:45
• I found this code, 'fs = 5e6; % sample rate N = 4096; % samples M1 = 173; % tone1 bin M2 = 211; % tone2 bin f1 = fs/NM1; % tone1 freq ~211KHz f2 = fs/NM2; % tone2 freq ~258Khz', in my case I have frequencies but I need to but them in a specific bins, I didn't know how to do it. beacuse the distance between the tones or the bins is useful to me after the nonlinearity in the receiver side.Thanks @jithin Mar 14, 2020 at 4:24