How to find the double trapezoidal integral of a function with 3 variables

3 次查看(过去 30 天)
Hi,
I have a function with 3 variables that I want to find the trapezoidal double integral of. My answer should be dependent on the last variable. I have tried using trapz, but I only get it to work when I give the undefined variable a value. Is there a way to use trapz in matlab, and still have an answer that is dependent on a variable?
Thanks!
Script:
clc; clear all; close all;
syms x
D1 = 0:1:3000;
D2 = 0:1:400;
[d1,d2] = meshgrid(D1,D2);
my_function = (d2./d1).*(x./d1).^(d2-1).*exp(-(x./d1).^d2)+((d2./d1)+d1.^2);
d = trapz(D2,trapz(D1,my_function,2))

回答(1 个)

Torsten
Torsten 2015-5-8
You can loop over a specified x-range, but you will not be able to get an expression for your integral as a function of x by the use of trapz.
Best wishes
Torsten.

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by