필터 지우기
필터 지우기

Using integral to define a function

조회 수: 1 (최근 30일)
DONGUK KIM
DONGUK KIM 2023년 11월 24일
편집: Dyuman Joshi 2023년 11월 24일
So I'm trying to define a function which has an integral inside.
Below is a simplified version of the function with the same error message: Unrecognized function or variable 'E'.
What I don't get is since variable E goes away after integral, shouldn't there be no reason for me to define it?
Also, how could this problem be resolved?
Thanks in advance.
result(0)
function test_integral = result(V)
test_integral = integral( @temp, E, -1, 1);
function tempf = temp(E)
tempf = E.*V;
end
end

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 11월 24일
편집: Dyuman Joshi 2023년 11월 24일
Remove the E from the integral() call, as it is not required.
Refer to the documentation of integral to know more about the syntax of the function.
result(2)
ans = -1.1102e-16
result(4)
ans = -2.2204e-16
result(6)
ans = -3.3307e-16
function test_integral = result(V)
test_integral = integral(@temp, -1, 1);
function tempf = temp(E)
tempf = E.*V;
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by