对二元向量函数integral2数值积分报错:对于此运算,数组大小不兼容的问题。
24 views (last 30 days)
Show older comments
程序如下:fuce = @(x,y)fun(x,y);
q = integral2(fuce,0,1,0,1)
function [a] = fun(x,y)
a = sin((1:5).*x + 2.*y);
end
想对此二元函数进行数值积分,但总出现报错:对于此运算,数组的大小不兼容。求教大神应该如何修改呐?
但把function定义的函数改为一元函数之后,就可以积分了:
fuce = @(x)fun(x);
q = integral2(fuce,0,1,'ArrayValued',true)
function [a] = fun(x)
a = sin((1:5).*x);
end
0 Comments
Accepted Answer
youwen
on 14 May 2023
clear;clc
fuce=@(a,x,y) sin(a*x + 2.*y);
q =arrayfun(@(a) integral2(@(x,y) fuce(a,x,y),0,1,0,1),(1:5));
首先,integral2不能像integral那样按照向量值函数对函数序列进行分别积分;
其次,用arrayfun 完成intergral2的向量各序列,像积分使用的原函数向量变成integral2的序列。
具体原理请参考如下链接,虽然不是很一致
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!