Need help in this error matrix integration

Hi, help, urgent, and I’m new. I am trying to do the following:
{E=10 nu=0.3 ebs=0 fun={@(x)1 @(x)x @(x)ebs ; @(x)x @(x)x^.2 @(x)x*ebs ; @(x)ebs @(x)x*ebs @(x)ebs.^2} A =cellfun(@(x)integral(x,-0.5,0.5),fun)}
And I get this error:
{Error using integralCalc/finalInputChecks (line 515) Output of the function must be the same size as the input. If FUN is an array-valued integrand, set the 'ArrayValued' option to true.
Error in integralCalc/iterateScalarValued (line 315) finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75) [q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct);
Error in matrix_integration>@(x)integral(x,-0.5,0.5)
Error in matrix_integration (line 19) A =cellfun(@(x)integral(x,-0.5,0.5),fun)
Can someone point what I am doing wrong?

답변 (1개)

Steven Lord
Steven Lord 2018년 9월 9일

0 개 추천

By default the integral function requires the integrand you pass into it as the first input argument to return an array the same size as the input. Several of the functions you've written do not satisfy that requirement. For example:
f = @(x)1
in = 1:10
out = f(in)
The variable in has 10 elements. The variable out has 1 element.
Use the 'ArrayValued' option in your integral call as the error message suggests.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2016b

질문:

2018년 9월 9일

답변:

2018년 9월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by