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

2 views (last 30 days)
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))

Answers (1)

Torsten
Torsten on 8 May 2015
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.

Community Treasure Hunt

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

Start Hunting!