double integration with a fzero function

2 views (last 30 days)
Yanhui
Yanhui on 11 Mar 2014
Try to integrate F(x)*exp(x) from -inf to inf, where F(x) is a integral of g(t) from R to inf. variable R is the root of R(x,R)=0 for a given x.
So I first define Rfun=@(R) R(x) and tfun=@(t) g(t) then use quad(@(x, t) exp(x).*g(t), fzero(Rfun,0), inf, -inf, inf).
The error is: Undefined function or variable 'x' in fzero.
How to link the outer integral variable to the fzero function that is used to define the lower limit of the inner integral?
Any help is appreciated.
Thanks, Yanhui
  2 Comments
Mike Hosea
Mike Hosea on 13 Mar 2014
What does "R is the root of R(x,R) = 0 for a given x." mean? It looks like R is a function of two variables, but you say it is a variable, so this must mean R*(x,R), but now I don't know what this comma operator is supposed to do. You have something equally weird in Rfun = @(R)R(x), which means Rfun is a function of a function that is evaluated at the constant value that x has when Rfun is defined, and your error message tells me that there was no such x in the workspace when you defined Rfun. R is supposed to be a variable, anyway, not a function, so I just can't figure out what problem you're trying to solve.
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 13 Mar 2014
@Yanhui
As Mike said, you have a math problem rather than a MATLAB problem, or maybe it's a typing problem, what ever it is, this term is absolutely wrong!
Rfun=@(R) R(x)
At least it should be
Rfun=@(x) R(x)
Take a second look at your equations! specially this one, make sure you don't have a math problem, then we can discuss the rest of the story ;)
Good Luck!

Sign in to comment.

Answers (0)

Categories

Find more on Optimization in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!