Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Problem trying to integrate a function

2 vues (au cours des 30 derniers jours)
Hyesun Cha
Hyesun Cha le 26 Avr 2015
Clôturé : MATLAB Answer Bot le 20 Août 2021
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?

Réponses (1)

Star Strider
Star Strider le 26 Avr 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.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by