Error using ^ when integrating a function

3 次查看(过去 30 天)
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.

采纳的回答

Walter Roberson
Walter Roberson 2024-3-7
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.

更多回答(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