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!