Problem trying to integrate a function
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
function rect = t1(x)
if x < 1 && x > -1
rect = 1;
else
rect = 0;
end
this was my function in a separate script file.
syms e x
pattern1 = t1(x);
ftpattern1 = int(pattern1*exp(-2*i*pi*e*x),x,-inf,inf);
Matlab keeps on giving a message that says I have an error in t1 if x < 1 && x > -1. I think I'm not allowed to give logical expression to symbols such as x... Any suggestions?
Respuestas (1)
Star Strider
el 26 de Abr. de 2015
You’re close, but you’re not defining it correctly.
The definition of a pulse in the Symbolic Math context:
syms x w t T
rect = heaviside(x+1) - heaviside(x-1);
figure(1)
ezplot(rect, [-2 2]) % Display Function
grid
However the correct way to define it in terms of calculating its Fourier transform is to define it as 1 between -T and +T:
syms x w t T
ftpattern1 = int(1*exp(-j*w*t), t, -T, T)
produces:
ftpattern1 =
(2*sin(T*w))/w
Here, you can define T=1, and plotting it:
ftpattern1 = subs(ftpattern1, T, 1)
figure(2)
ezplot(ftpattern1, [-10*pi, 10*pi])
grid
This is the expected result.
La pregunta está cerrada.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!