Error in nested integration

조회 수: 2 (최근 30일)
Shweta Rajoria
Shweta Rajoria 2017년 11월 22일
댓글: Shweta Rajoria 2017년 11월 24일
I want to integrate a function and program is given below:
close all;
clear all;
fun = @(x,y)x+(x./(y.^2));
fun1= @(y) y+ integral(@(x)fun(x,y), 0,1);
c1= integral(fun1,0,1)
In the above program if we are using 'y' instead of 'y.^2', then there is no error. But if we are using 'y.^2' error occurred matrix dimension must agree. But here we are using x, y as variable hence there should be no question of matrix dimension. If, anybody can solve the problem please help me . Any suggestions regarding this will be appreciated.

채택된 답변

Torsten
Torsten 2017년 11월 22일
fun1= @(y) y+ integral(@(x)fun(x,y), 0,1,'ArrayValued',true);
Note that fun is undefined at y=0. Thus c1 should come out as Inf.
Best wishes
Torsten.
  댓글 수: 3
Torsten
Torsten 2017년 11월 24일
I guess that the division by x^q for x=0 in "fun" is the problem.
Best wishes
Torsten.
Shweta Rajoria
Shweta Rajoria 2017년 11월 24일
Thank you sir.. my problem is solved with your suggestion.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by