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

조회 수: 3 (최근 30일)
Trond Oesten
Trond Oesten 2015년 5월 8일
답변: Torsten 2015년 5월 8일
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