The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: numerically integrating a function of 3 variables with respect to 2 of them
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List

Posts: 3
Registered: 2/25/08
numerically integrating a function of 3 variables with respect to 2 of them
Posted: Feb 17, 2013 12:47 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Matlab people:

I have spent a lot of time Googling this question and I haven't found an answer. I apologize if it has been answered elsewhere. The actual m-files I'm using are on a remote server and I don't know how to upload them here. But if someone knows the answer it should not be necessary.

I have a function H of 3 variables defined in an m-file. The function uses algebraic functions and the heaviside function. The function works. I am trying to integrate H(r0,r1,sigma) as (r0,r1) ranges over a square. I can't just use dblquad because H is a function of 3 variables. So I wrote an m-file containing the following:

function out = I2(sigma,Rmax)
%second (double) integral
function out1 = Hsigma(r0,r1)
out1 = H(r0,r1,sigma);
out = dblquad(Hsigma,1,Rmax,1,Rmax);

I get a warning about the scope of sigma spanning multiple functions. When I try to use I2, I get the following error:

>> I2(2,2)
Error using I2/Hsigma (line 6)
Not enough input arguments.

Error in I2 (line 10)
out = dblquad(Hsigma,1,Rmax,1,Rmax);

NOTE: line 6 is "out1 = H(r0,r1,sigma); ".

Can anyone suggest a solution?


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.