1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Composite Simpsons 1/3 matlab code

  1. May 10, 2014 #1


    User Avatar

    hey guys,
    So I'm working on a matlab function that uses simpsons 1/3 rule to find an integral.
    This is what I have done so far, but I'm not 100% confident..
    If anyone would be able to have a look at give me some tips that would be very much appreciated.

    function [ I ] = simpsons3( func,a,b,n )
    %Finds estimate integral from a to b of function using simpson 1/3 rule

    % % INPUTS
    % % func = function
    % % a = lower limit
    % % b = upper limit
    % % n=number of segments used for integration
    % % OUTPUTS
    % % I = integral estimate

    h = (b-a)/(n-1);
    sumE = 0;
    for i = a+2*h:h:b-2*h
    sumE = sumE + func(i);
    sumO = 0;
    for i = a+h:h:b-h
    sumO = sumO + func(i);
    I = (h/3)*(func(a)+4*sumE+2*sumO+func(b));
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Threads - Composite Simpsons matlab Date
3DES or RSA implementation for optics in MATLAB Jun 16, 2016
Ansys workbench Composite Analysis Mar 12, 2016
Tube with ultrathin wall Apr 5, 2015