Output of an integral function as a function

Hi all,
Everyone can tell me how to make the output of an integral function as a function, please? I try the following code, but the result is wrong.
>> f0=@(x) x^2;
>> f1=@(x) (x*quad(@(x) f0,0,2));
>> f0(4)
ans =
16 (>>>>> *good result*)
>> f1(4)
Warning: Maximum function count exceeded; singularity likely. > In quad at 106 In @(x)(x*quad(@(x)f0,0,2))
ans =
57.1751 (>>>>>> *bad result*)
Thank you in advance for your help!!!
Tuan

댓글 수: 4

Try
f1=@(x) (x*quad(f0,0,2));
Tuan
Tuan 2012년 10월 15일
Thank you so much for your prompt answer. But Matlab shows me the error:
??? Error using ==> mpower Inputs must be a scalar and a square matrix.
Error in ==> @(x)x^2
Error in ==> quad at 77 y = f(x, varargin{:});
Error in ==> @(x)(x*quad(f0,0,2))
Do you have another idea? Thanks you!
Tuan
Tuan
Tuan 2012년 10월 15일
편집: Tuan 2012년 10월 15일
Thank Walter Roberson! I have a right result now. Hope that works with triple integral (triplequad). I would like to accept your answer, but this button is no longer appeared when I make my comment. Sorry!

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

질문:

2012년 10월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by