Calculating FT using matlab quad function

  • Context: MATLAB 
  • Thread starter Thread starter lefti2003
  • Start date Start date
  • Tags Tags
    Function Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 5K views
lefti2003
Messages
1
Reaction score
0
Hi All,
I am new to this forum and new to using the quad function. Some assistance would be most helpful. I appreciate all help in advance.

I have a .m file called OneExpDecay.m that has the following

syms t
x=exp(-2*t^2);
[RX,IX]=ft(x,-inf,inf);

then I have an ft.m that has the following

function [RX,IX]=ft(x,a,b)
syms t f
fr=@(t)x*cos(2*pi*f.*t);
RX=quad(fr,a,b);
fim=@(t)x*sin(2*pi*f.*t);
IX=-quad(fim,a,b);

When I run OneExpDecay.m I get the following errors that I do not understand how to resolve

?? Undefined function or method 'isfinite' for input arguments of type 'sym'.

Error in ==> quad at 81
if ~isfinite(y(1))

Error in ==> ft at 4
RX=quad(fr,a,b);

Error in ==> OneExpDecay at 3
[RX,IX]=ft(x,-inf,inf);





Thanks
Lefti
 
Physics news on Phys.org
The error that your receiving about functions being undefined for inputs of type sym means that you're trying to send a symbol into a function that is expecting a number (or numbers).

Here, my guess is that you need to use finite limits (inf and -inf won't cut it). Try replacing them with numbers.

Hope this helps.

-Kerry