我要求积分的简单例子
a = max(solve(x^3 - 2*x^2 + x ==0 , x));
fun = @(x) exp(-x.^2).*log(x).^2;
q = integral(fun,0,a)
错误是
Error using integral (line 85)
A and B must be floating-point scalars.
有什么建议吗?我的积分下限必须是一个函数,而不是一个数字。
最佳答案
Matlab 命令 solve
返回符号结果。 integral
只接受数字输入。使用 double
将符号转换为数字。现在编写代码时,max
应该会因符号输入而引发错误。以下作品。
syms x;
a = max(double(solve(x^3 - 2*x^2 + x)));
fun = @(x) exp(-x.^2).*log(x).^2;
q = integral(fun,0,a)
输出:1.9331
。
the lower limit of my integral must be a function, not a number
integral
是一个数值积分例程;积分的限制必须是数字。
关于matlab - 使用积分 : A and B must be floating-point scalars 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29804749/