double integration with a fzero function

조회 수: 4 (최근 30일)
Yanhui
Yanhui 2014년 3월 11일
댓글: Salaheddin Hosseinzadeh 2014년 3월 13일
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
Mike Hosea
Mike Hosea 2014년 3월 13일
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 2014년 3월 13일
@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!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by