필터 지우기
필터 지우기

Error using ^ when integrating a function

조회 수: 3 (최근 30일)
Fuad
Fuad 2024년 3월 7일
답변: Walter Roberson 2024년 3월 7일
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