How to find phase and frequency spectrum of signal?

22 ビュー (過去 30 日間)
Ihor
Ihor 2023 年 11 月 17 日
コメント済み: Paul 2023 年 11 月 17 日
I have a signal:
t = -2:0.01:2;
x = zeros(size(t));
x(t >= -2 & t < -1) = -1;
x(t >= 0 & t <= 2) = -1;
how I can find frequency and phase spectrum of this signal? I need to plot all of it.
  1 件のコメント
Paul
Paul 2023 年 11 月 17 日
What is the value of x(t) for abs(t) > 2?

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

回答 (1 件)

Star Strider
Star Strider 2023 年 11 月 17 日
A one-sided fft
t = -2:0.01:2;
x = zeros(size(t));
x(t >= -2 & t < -1) = -1;
x(t >= 0 & t <= 2) = -1;
figure
plot(t, x)
grid
xlabel('t')
ylabel('x')
title('Time Domain Plot of ‘x(t)’')
axis('padded')
Fs = 1/mean(diff(t));
Fn = Fs/2;
L = numel(t);
NFFT = 2^nextpow2(L);
FTx = fft(x(:).*hann(L), NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
figure
tiledlayout(2,1)
nexttile
plot(Fv, abs(FTx(Iv))*2)
grid
ylabel('Magnitude (absolute)')
nexttile
plot(Fv, unwrap(angle(FTx(Iv))))
grid
xlabel('Frequency (cycles/(time unit))')
ylabel('Phase (rad)')
sgtitle('One-Sided Fourier Transform of ‘x(t)’')
Make appropriate changes to get the result you want.
.
  1 件のコメント
Paul
Paul 2023 年 11 月 17 日
Doesn't some adjustment need to be made to the phase to account for the fact that the signal "starts" in negative time, but fft assumes the the first point in the input corresponds to t = 0?

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

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by