フィルターのクリア

fouriertransform with piecewise function

11 ビュー (過去 30 日間)
Elisa
Elisa 2022 年 12 月 11 日
編集済み: Paul 2022 年 12 月 13 日
I am trying to apply a fft (fourier transform) into a piecewise function, but i receive the following message: "Error using fft
Invalid data type. First argument must be double, single, int8, uint8, int16, uint16, int32, uint32, or logical."
Code:
figure(1);
syms t
x = piecewise(-1/2<=t<=1/2, 1-abs(t), t<-1/2, 0 , t>1/2, 0);
fplot(x,[-2,2])
grid
xlabel("Time")
ylabel("Amplitude")
fa = 15000;
t = 0:1/fa:2;
y=fft(x);
f = -fa:1:fa;
figure(2);
subplot(2,1,1);
plot(f,abs(y_ajustado)/fa);
xlabel("Frequency (Hz)")
ylabel("Amplitude")
xlim([0 400])
subplot(2,1,2)
plot(f,angle(y_ajustado));
xlabel("Frequency (Hz)")
ylabel("Fase (Graus)")
xlim([0 400])

採用された回答

VBBV
VBBV 2022 年 12 月 11 日
use double and subs() the result of x
figure(1);
syms t
x = piecewise(-1/2<=t<=1/2, 1-abs(t), t<-1/2, 0 , t>1/2, 0)
x = 
fplot(x,[-2,2])
grid
xlabel("Time")
ylabel("Amplitude")
fa = 15000;
t = 0:1/fa:2;
y=fft(double(subs(x,t)));
plot(t,real(y),t,imag(y))
  2 件のコメント
Elisa
Elisa 2022 年 12 月 12 日
thank you!!!!
Paul
Paul 2022 年 12 月 12 日
編集済み: Paul 2022 年 12 月 13 日
Why is y plotted agains t? Shouldn't y be plotted against frequency? And the fft is only taken for the portion of the signal for t>=0, but it's non-zero for t < 0.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by