Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: How to calculate a matrix-based integral

Subject: How to calculate a matrix-based integral

From: Xueou Chen

Date: 16 May, 2008 06:31:02

Message: 1 of 4

I have a matrix-based integrand, i.e., including some
matrix calculations, like f(x) = A*B*C, A is a row vector,
B a matrix, C a column vector, all associated with x. and
f(x) still a single number function of x.

Now when I use function quadl to calculate int(f(x)), the
input x is always a vector, and it tells me error of matrix
dimention...

I have to calculate the above matrix formulas on paper to
avoid such errors. But f(x) actually includes matrix
inversion. 3 * 3 is still ok, then 4 * 4 matrix ... very
boring.

I think there are some other ways to do this better.

Subject: Re: How to calculate a matrix-based integral

From: John D'Errico

Date: 16 May, 2008 09:45:03

Message: 2 of 4

"Xueou Chen" <hicxo@sina.com> wrote in message
<g0j9n6$286$1@fred.mathworks.com>...
> I have a matrix-based integrand, i.e., including some
> matrix calculations, like f(x) = A*B*C, A is a row vector,
> B a matrix, C a column vector, all associated with x. and
> f(x) still a single number function of x.
>
> Now when I use function quadl to calculate int(f(x)), the
> input x is always a vector, and it tells me error of matrix
> dimention...

quadl can call your function with multiple
x values all at once. But, Matlab has a for
loop that you can use.

Put one inside your code, to compute your
function for each value of x that is passed
in.

John

Subject: Re: How to calculate a matrix-based integral

From: Xueou Chen

Date: 19 May, 2008 08:28:02

Message: 3 of 4

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <g0jl2v$mn6$1@fred.mathworks.com>...
> "Xueou Chen" <hicxo@sina.com> wrote in message
> <g0j9n6$286$1@fred.mathworks.com>...
> > I have a matrix-based integrand, i.e., including some
> > matrix calculations, like f(x) = A*B*C, A is a row
vector,
> > B a matrix, C a column vector, all associated with x.
and
> > f(x) still a single number function of x.
> >
> > Now when I use function quadl to calculate int(f(x)),
the
> > input x is always a vector, and it tells me error of
matrix
> > dimention...
>
> quadl can call your function with multiple
> x values all at once. But, Matlab has a for
> loop that you can use.
>
> Put one inside your code, to compute your
> function for each value of x that is passed
> in.
>
> John

thank you.

I have already tried this way before I posted here. It can
work anyway. But my integral is from -Inf to +Inf, the
exact integral range is decided by the precision
aotomatically. So there is a lot of calculations of my
integrand function. Then a for loop will slow down my codes
very much, so I posted here to find a better way.

hicxo

Subject: Re: How to calculate a matrix-based integral

From: John D'Errico

Date: 19 May, 2008 09:54:01

Message: 4 of 4

"Xueou Chen" <hicxo@sina.com> wrote in message
<g0rdmi$ko5$1@fred.mathworks.com>...

> I have already tried this way before I posted here. It can
> work anyway. But my integral is from -Inf to +Inf, the
> exact integral range is decided by the precision
> aotomatically. So there is a lot of calculations of my
> integrand function. Then a for loop will slow down my codes
> very much, so I posted here to find a better way.

If your integrand is such that you will
define different finite limits based on
your parameters, then this is impossible
to accomplish using quadl. Quadl is an
adaptive quadrature, but it uses only
one set of limits.

A for loop, external to the quadrature,
is then the solution.

John

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
integrand matrix Xueou Chen 19 May, 2008 04:30:10
integrand matrix dimention Xueou Chen 16 May, 2008 02:35:04
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics