Venus8588
Venus8588

Reputation: 15

understanding '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'

I'm trying to numerically integrate my function log(1+A.*exp(-t.^2)) from -Inf to Inf where A is a 80x1 matrix. When I used the integral function, it shows error that

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

yprime = integral( @(t) (log(1+ A.*exp(-t.^2))),-Inf,Inf );

I expected a yprime matrix of 80x1, but it doesn't!

Upvotes: 0

Views: 1427

Answers (1)

Andrew Janke
Andrew Janke

Reputation: 23858

Just do as the error message suggests. When Matlab tells you to set a named option for a function, that means to supply the option name and the value for it as trailing arguments to the function.

>> yprime = integral( @(t) (log(1+ A.*exp(-t.^2))), -Inf, Inf, 'ArrayValued', true );
>> size(yprime)
ans =
    80     1

Upvotes: -1

Related Questions