Effacer les filtres
Effacer les filtres

Error using ^ when integrating a function

3 vues (au cours des 30 derniers jours)
Fuad
Fuad le 7 Mar 2024
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 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.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by