Thread Subject: problem finding FT of a function using quad

Subject: problem finding FT of a function using quad

From: El

Date: 25 Nov, 2009 01:48:19

Message: 1 of 3

Hi All,
 I enter a function at command line
>>x=1/exp(pi*t^2)

I then call a function as below
[RX,IX]=ft(x,-inf,inf)

where the function ft is below


function [RX,IX]=ft(x,a,b)
syms t f real

RX=quad('x*cos(2*f*pi*t)',a,b);
IX=-quad('x*sin(2*f*pi*t)',a,b);
RX=simplify(RX);
IX=simplify(IX);

i get the following error

??? Error using ==> inline.subsref at 14
Not enough inputs to inline function.

Error in ==> quad at 77
y = f(x, varargin{:});

Error in ==> ft at 6
RX=quad('x*cos(2*f*pi*t)',a,b);
 

What is the problem. Thanks for your help

Subject: problem finding FT of a function using quad

From: Zhaopei Song

Date: 25 Nov, 2009 02:34:17

Message: 2 of 3

hi,
  I think the problem lie to the fact that quad function accepts only 1 "sym" variable. So, sym(f) and sym(t) in your function input have caused the error.
 In the line 81 of function "quad" is
 % if ~isfinite(y(1))
 You could see that only numbers are supported.

"El " <el_stamatakos@hotmail.com> wrote in message <hei2d3$ls8$1@fred.mathworks.com>...
> Hi All,
> I enter a function at command line
> >>x=1/exp(pi*t^2)
>
> I then call a function as below
> [RX,IX]=ft(x,-inf,inf)
>
> where the function ft is below
>
>
> function [RX,IX]=ft(x,a,b)
> syms t f real
>
> RX=quad('x*cos(2*f*pi*t)',a,b);
> IX=-quad('x*sin(2*f*pi*t)',a,b);
> RX=simplify(RX);
> IX=simplify(IX);
>
> i get the following error
>
> ??? Error using ==> inline.subsref at 14
> Not enough inputs to inline function.
>
> Error in ==> quad at 77
> y = f(x, varargin{:});
>
> Error in ==> ft at 6
> RX=quad('x*cos(2*f*pi*t)',a,b);
>
>
> What is the problem. Thanks for your help

Subject: problem finding FT of a function using quad

From: Steven Lord

Date: 27 Nov, 2009 00:04:52

Message: 3 of 3


"El " <el_stamatakos@hotmail.com> wrote in message
news:hei2d3$ls8$1@fred.mathworks.com...
> Hi All,
> I enter a function at command line
>>>x=1/exp(pi*t^2)

This is not a function. This is an expression.

> I then call a function as below
> [RX,IX]=ft(x,-inf,inf)
>
> where the function ft is below
>
>
> function [RX,IX]=ft(x,a,b)
> syms t f real
>
> RX=quad('x*cos(2*f*pi*t)',a,b);

*snip*

In general, if you're integrating a symbolic expression you should use INT
instead of QUAD or QUAD-related functions.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com