Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Problem trying to integrate a function

조회 수: 1 (최근 30일)
Hyesun Cha
Hyesun Cha 2015년 4월 26일
마감: MATLAB Answer Bot 2021년 8월 20일
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?

답변 (1개)

Star Strider
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.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by