Info
此问题已关闭。 请重新打开它进行编辑或回答。
Problem trying to integrate a function
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Star Strider
2015-4-26
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.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!