Problem with the evaluation of the product of triple integral
1 次查看(过去 30 天)
显示 更早的评论
Consider a set of positive values
,
and
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/789510/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/789515/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/789520/image.png)
How can I compute q passing the integrand function as a function handle ? With the followind code an error occurs...
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/789525/image.png)
% Inputs:
t = 15;
sigma = 0.25;
y = [1.0 1.2]';
h = @(x1,x2,x3) x1.*(t - x2).^x3;
g = @(x1,x2,x3) exp(-0.5.*((y - h(x1,x2,x3))./sigma).^2 );
q = prod(integral3(@(x1,x2,x3) g(x1,x2,x3), 0, 1, 0, t, 0.3, 1));
0 个评论
采纳的回答
Yongjian Feng
2021-11-4
y is an array. You can't use it directly in integral3. Do the product yourself as a for loop.
t = 15;
sigma = 0.25;
y = [1.0 1.2]';
accu = 1;
for i = 1:length(y)
h = @(x1,x2,x3) x1.*(t - x2).^x3;
g = @(x1,x2,x3) exp(-0.5.*((y(i) - h(x1,x2,x3))./sigma).^2 );
q = integral3(@(x1,x2,x3) g(x1,x2,x3), 0, 1, 0, t, 0.3, 1);
accu = accu * q;
end
accu
3 个评论
Yongjian Feng
2021-11-4
Use arrayfun
y = [1.0 1.2];
result = prod(arrayfun(@(x) int3(x), y));
function q = int3(y)
t = 15;
sigma = 0.25;
h = @(x1,x2,x3) x1.*(t - x2).^x3;
g = @(x1,x2,x3) exp(-0.5.*((y - h(x1,x2,x3))./sigma).^2 );
q = integral3(@(x1,x2,x3) g(x1,x2,x3), 0, 1, 0, t, 0.3, 1);
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Construction 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!