Error using ^ when integrating a function

2 views (last 30 days)
I am attempting to integrate a function between its bounds.
fun = @(r) (1+erf((-36.38+2.56*log(5+((138.4-r)/4)*((26.964*2.71828^(-0.0238*r))^(4/3)))-5)/sqrt(2))*r);
q = integral(fun,21.2,140)
I get the below error.
Error using ^
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To operate on each element of the matrix individually, use POWER (.^) for elementwise power.

Accepted Answer

Walter Roberson
Walter Roberson on 7 Mar 2024
fun = @(r) (1+erf((-36.38+2.56.*log(5+((138.4-r)/4).*((26.964*2.71828.^(-0.0238*r)).^(4/3)))-5)/sqrt(2)).*r);
Use vectorized operations.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!