I have a signal with centre at 0.5Khz, how can i shift the signal such that the maximum component occurs at the center of the frequency axis?

3 ビュー (過去 30 日間)
figure(3)
Fs=1e6;
t = 0:1/Fs:1.5;
L = length(t);
n = 2^nextpow2(L);
y=fft(signal,n);
f = Fs*(0:(n/2))/n;
P = abs(y/n);
plot(f,P(1:n/2+1))
  1 件のコメント
Kunal Khosla
Kunal Khosla 2019 年 4 月 4 日
%% Building signal %%%
f0=0.5; % central frequency, MHz
t0=1.5; % pulse center time
bndwdth=10; % pulse -6dB bandwidth
duration=2*t0; % signal length
% Gausspuls by default gives unity amplitude
timebase=(0:round(duration/dt)-1)'*dt;
[signalI,signalQ]=gauspuls(timebase-t0,f0,bndwdth);
signal=20*signalQ;

サインインしてコメントする。

採用された回答

Agnish Dutta
Agnish Dutta 2019 年 4 月 16 日
I have assumed that the signal has only 1 peak. In case of multiple peaks, the "find(P == max(P), 1)" command will return an array of indices, each corresponding to a different maximum value in the signal.
I suppose shifting the peak signal value to the center, can be done in two ways depending on where the peak is occurring in the signal.
If the peak occurs before the mid point, then find the value of the signal at as many points before the very first one as the peak is from the mid point. Then concatenate these values to the beginning of the signal array. For the sake of demonstrating I have assumed that these values are zero and come up with teh following:
new_P = [zeros(length(P)/2 - find(P == max(P), 1, 'first'), 1); P];
Similarly if the peak occurs after the midpoint:
new_P2 = [P; zeros(find(P == max(P), 1, 'last') - length(P)/2, 1)];
If, on the other hand you want to change the axes range for plotting the signal, such that the peak appears at the centre, then you can find the index of the peak value using:
find(P == max(P), 1, 'first');
Then, use this value to set the axes range and aspect ratios as shown in the following document:
  1 件のコメント
Kunal Khosla
Kunal Khosla 2019 年 4 月 16 日
編集済み: Kunal Khosla 2019 年 4 月 16 日
Thanks Agnish Dutta
I would like to direct your attention to this question towards a follow up post.
Kindly also help me in the choice of the correct sampling frequency for the program for the gicen bandwidth.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by