how to define an integral function
조회 수: 19 (최근 30일)
이전 댓글 표시
I want to define a function in the integral form
f(x)=integral(g(z), z=0, z=x)
as an example:
for which I wrote:
fun = @(z) z^2+3*z-1;
x=linspace(0,1,100);
y = integral(fun,0,@(x) x)
plot(x,y)
But Matlab returned the following error:
Error using integral (line 85)
A and B must be floating-point scalars.
Error in IntegralFunction (line 8)
y = integral(fun,0,@(x) x)
Is it possible at all to do this in Matlab?
댓글 수: 0
채택된 답변
Torsten
2018년 9월 6일
fun=@(z)z.^2+3*z-1;
F=@(x)integral(fun,0,x);
F(10)
댓글 수: 5
Aishwarya Kasarla
2023년 4월 1일
Hey, I am also stuck with the same proble, did you find the solution? Can you please help me out with this?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!