Berker 0 Report post Posted June 3, 2018 Hello, I want to calculate numerical integration in Compose. I am using Compose 2017.3. In another script in Matlab 2016a, I was using integral2 function. I searched, but couldn't find this function in Compose. Is there another function available in Compose to calculate numerical integration? Thank you Berker Quote Share this post Link to post Share on other sites

Berker 0 Report post Posted June 3, 2018 Hello, I thought I need to provide more details regarding my question. Below please find a sample code I was running in Matlab 2016a. Here, I am using "integral2" to calculate the double integral. This function was not available in Compose 2017.3. I try to use "quad," but I am not sure whether that function calculated double layer integral. Is there another function that I can use to calculate double layer integral? clear all; close all; clc; rr1=0.0305; rr2=0.0415; xmin=0; xmax=0.005416836077132; f = @(x,y) x.^2 + y.^2; ymin = @(x) sqrt(rr1^2 - x.^2); ymax = @(x) sqrt(rr2^2 - x.^2); moment = 2*integral2(f, xmin, xmax, ymin, ymax); matlab_result=1.5624e-7; disp(moment); Thank you Berker Quote Share this post Link to post Share on other sites

Guest Report post Posted June 5, 2018 Hello Berker, The best way to implement this in Compose is to nest trapz and quad functions. The following code may help you to solve your issue. global rr1; global rr2; rr1 = 0.0305; rr2 = 0.0415; function q = f(x) global rr1; global rr2; g = @(y) (x*x + y.*y); v = [sqrt(rr1^2-x^2):0.000001:sqrt(rr2^2-x^2)]; q = trapz(v, g(v)); end xmin = 0; xmax = 0.005416836077132; moment = 2*quad(@f, xmin, xmax, [1.0e-10, 1.0e-10]) Thanks, Sijo George Quote Share this post Link to post Share on other sites