MATLAB Calculating FT using matlab quad function

  • Thread starter Thread starter lefti2003
  • Start date Start date
  • Tags Tags
    Function Matlab
AI Thread Summary
The discussion centers on a user seeking help with a MATLAB script that utilizes the quad function for numerical integration. The user encounters an error related to the 'isfinite' function when running their script, which indicates that symbolic inputs are being passed to a function that requires numeric values. The suggested solution is to replace the infinite limits in the integration with finite numerical values, as the quad function cannot handle symbolic limits like -inf and inf. This adjustment is expected to resolve the error and allow the script to run successfully.
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
 

Similar threads

Replies
8
Views
2K
Replies
4
Views
1K
Replies
5
Views
3K
Replies
4
Views
1K
Replies
1
Views
2K
Replies
5
Views
2K
Replies
1
Views
2K
Back
Top