How to do integrals and fft on matlab

I am extremely new to using matlab and I am trying to get the basic integral function to work. I want to find the fft of a function, and the integral to graph. However, whenever I use the int function, I get errors.
int(sqrt(2)*cos((pi/2)*t).*exp(-j*w*t),t)
gives me the error "Undefined function 'int' for input arguments or 'double'."
It may be easier to just do the fft of the original function sqrt(2)*cos(pi/2*t) but I can't seem to get this to work and give me a graph of the spectrum either. Any thoughts?

 Risposta accettata

syms w t
f = sqrt(sym(2))*cos(sym(pi)/sym(2)*t)*exp(-j*w*t);
F = int(f,t)

1 Commento

Thank you, that worked! So I'm trying to find the spectrum of this signal and nothing I try is working. I tried the following but it seems to get into an endless loop and never fully constructs itself.
t = -2:1/fs:2;
y = sqrt(2)*cos(pi/2*t); %generating half cosine wave
y(abs(t)>1) = 0;
Y = fft(y);
Y = fftshift(Y);
syms t
SpectrumY = int(Y,t);
figure;
plot(SpectrumY,t)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Fourier Analysis and Filtering in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by