Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error in using int() !!!!

0 views
Skip to first unread message

Animesh Pandey

unread,
Apr 16, 2011, 10:18:05 AM4/16/11
to
clc
syms t w
int(a);
I = sqrt(-1);
f = @(t) 0.5*(((t+0.5*a)./abs(t+0.5*a)) - ((t-0.5*a)./abs(-t+0.5*a)));
pretty(f(t));
H = int(f(t).*exp(-I*w*t), t, -Inf, Inf);
pretty(H);

The 'H' is coming out to be NaN.
'a' is a constant .....
'H' is basically the Fourier Transform of f(t).
If f(t) = heaviside(t+0.5*a) - heaviside(t-0.5*a), then it works fine .....
I don't know where I am going wrong !!??
Please help !!!
THanx

Lisa Oziel

unread,
Apr 16, 2011, 1:28:04 PM4/16/11
to
"Animesh Pandey" wrote in message <ioc8et$9g6$1...@fred.mathworks.com>...

Are you sure I=sqrt of -1 and when you use the pretty function you just need f same for int use int(f) . The reason for it because you defined t as your variable. Also you have the variable a defined right? Sqrt of negative n umber would get you an imaginary number. Other than that I do not see anything wrong with your code.

Animesh Pandey

unread,
Apr 17, 2011, 5:58:04 AM4/17/11
to
"Lisa Oziel" <Lisa_...@yahoo.com> wrote in message <iocjj4$rdk$1...@fred.mathworks.com>...

-------------------------------------------------------------------------------------------------------------
Pretty(H) does not give any error if I replace 'a' by an integer.
But I want 'H' to be general.


'H' is basically the Fourier Transform of f(t).

clc
syms t w a


I = sqrt(-1);
f = @(t) 0.5*(((t+0.5*a)./abs(t+0.5*a)) - ((t-0.5*a)./abs(-t+0.5*a)));

pretty(f(t)); %gives correct plot


H = int(f(t).*exp(-I*w*t), t, -Inf, Inf);

pretty(H); %NaN

Steven_Lord

unread,
Apr 18, 2011, 11:42:38 AM4/18/11
to

"Animesh Pandey" <apanim...@gmail.com> wrote in message
news:ioc8et$9g6$1...@fred.mathworks.com...

Do NOT keep starting new threads for the same or extremely similar
questions!

http://www.mathworks.com/matlabcentral/newsreader/view_thread/306361
http://www.mathworks.com/matlabcentral/newsreader/view_thread/306346
http://www.mathworks.com/matlabcentral/newsreader/view_thread/306320
http://www.mathworks.com/matlabcentral/newsreader/view_thread/306282
http://www.mathworks.com/matlabcentral/newsreader/view_thread/305989

Please choose ONE thread and continue the discussion in THAT ONE thread.

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

0 new messages