Jump to content
Berker

Numerical Integral

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Guest

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...