% ======================================================================== % ***************** Integration by Simpson's 3/8 method ****************** % *************************** By Mahesha MG ****************************** % Date: 25/02/2013 % ======================================================================== display('Equation is x^2+x-2') xl=input('Enter lower limit:'); xu=input('Enter upper upper limit: '); n=input('Enter number of subintervals: '); % ======================================================================== h=(xu-xl)/n; x=xl+h; integ=equan(xl)+equan(xu); i=1; while (x<xu) if (i<=2) integ=integ+3*equan(x); i=i+1; else integ=integ+2*equan(x); i=1; end x=x+h; end integ=integ*3*h/8 % ========================================================================
% Equation to be solved function[eqn]=equan(x); eqn=x^2+x-2;
Can you please give the MATLAB code for n point too??
ReplyDeleteI will try to develop that.
ReplyDeletehi
ReplyDelete??? Undefined function or method 'equan' for input arguments of type 'double'.
ReplyDelete