Azzera filtri
Azzera filtri

fouriertransform with piecewise function

11 visualizzazioni (ultimi 30 giorni)
Elisa
Elisa il 11 Dic 2022
Modificato: Paul il 13 Dic 2022
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])

Risposta accettata

VBBV
VBBV il 11 Dic 2022
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 Commenti
Paul
Paul il 12 Dic 2022
Modificato: Paul il 13 Dic 2022
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by