Matlab:如何计算函数在多个极限上的定积分?

标签 matlab integrate limits

假设:

z = [0.4 0.5 0.75]'  
function y = myfunct(x)  
y = quad(@sin, 0, x)

我想计算 sin(x) 从 0 到 0.4、0.5 和 0.75 的定积分,使用:

myfunct(z)

但是,Matlab 返回:

??? Error using ==> quad at 70  
The limits of integration must be scalars.  

如果您有任何建设性的建议,我将不胜感激。

最佳答案

您可以在最新版本的 MATLAB 中使用 arrayfun 函数:

z = [0.4 0.5 0.75]';
y = arrayfun(@(upperLim)(quad(@sin,0,upperLim)),z);

关于Matlab:如何计算函数在多个极限上的定积分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7785314/

相关文章:

matlab - 在 matlab 中绘制 3d 贝壳

matlab - 矢量化:矩阵数组乘法逐个元素

c++ - 为什么 Visual Studio 在 64 位平台上链接 MSVCR90.dll (x86)?

css - 如何将 javascript 控件集成到现有的 css 站点中?

annotations - Microsoft Dynamics CRM 2016 特定实体属性的数据大小限制的文档

MATLAB:安全共享函数

wolfram-mathematica - 这是 Mathematica 8 的错误吗?

java - 安卓 - PDF Int。 - 新实例失败 - 无法实例化

html - CSS:一个 HTML 元素可以有多少个类有限制吗?

bash - 如何使用 bash 测试文件系统的目录限制