Calculating FT using matlab quad function

  • Context: MATLAB 
  • Thread starter Thread starter lefti2003
  • Start date Start date
  • Tags Tags
    Function Matlab
Click For Summary
SUMMARY

The forum discussion centers on using the MATLAB quad function to calculate the Fourier Transform (FT) of a symbolic expression defined in the OneExpDecay.m file. The user encounters an error related to the isfinite function when attempting to use infinite limits in the ft.m function. The solution provided suggests replacing the infinite limits with finite numerical values to resolve the issue.

PREREQUISITES
  • Familiarity with MATLAB programming and syntax
  • Understanding of symbolic mathematics in MATLAB
  • Knowledge of Fourier Transform concepts
  • Experience with numerical integration techniques in MATLAB
NEXT STEPS
  • Explore MATLAB's integral function as an alternative to quad for numerical integration
  • Learn about defining and manipulating symbolic variables in MATLAB
  • Study the implementation of Fourier Transforms using MATLAB's fft function
  • Investigate error handling in MATLAB to manage function input types
USEFUL FOR

This discussion is beneficial for MATLAB users, particularly those engaged in symbolic computation and numerical integration, as well as students and professionals working on Fourier Transform applications.

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 1 ·
Replies
1
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K