error while executing textbook MATLAB code?

Capture.PNG
I am studying Fourier transform through book of alex palamides and it states that there is a property of fourier transform due to which convolution of two time domain signals is equal to inverse fourier*(product of fourier transforms of signals)
But when i try to put this concept to MATLAB as demonstrated in book , i get error shown in attached photo. Although i have wrote exactly same code as on page 312 of Book
My code is follow:
syms t w
x1=heaviside(t)-heaviside(t-2);
x2=heaviside(t)-heaviside(t-4);
X1=fourier(x1,w);
X2=fourier(x2,w);
right =ifourier(X1*X2,t);
ezplot(right,[0 8])

 채택된 답변

Walter Roberson
Walter Roberson 2019년 5월 18일

0 개 추천

In your release of MATLAB, ezplot() was not compatible with plotting symbolic expressions, and fplot() had to be used instead.
However, the ifourier() is giving unusable results that neither ezplot() nor fplot() can use.
The work-around, valid from R2012a, is:
right = ifourier( rewrite(X1*X2, 'exp'), t);
fplot(right, [0 8])

댓글 수: 3

ABTJ
ABTJ 2019년 5월 18일
When i try your suggestion i get following error:
Error using fcnchk (line 106)
If FUN is a MATLAB object, it must have an feval method.
Error in fplot (line 60)
fun = fcnchk(fun);
Error in Untitled3 (line 10)
fplot(right, [0 8])
Hmmm. Try
fplot( matlabFunction(right), [0 8])
ABTJ
ABTJ 2019년 5월 19일
This line worked out. Thanks walter

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2015a

질문:

2019년 5월 14일

댓글:

2019년 5월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by