Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- disp("------------------------Simpson's 1/3rd Rule------------------------")
- str = input('Give an equation in x: ','s') ;
- % a = input('Enter lowerbound value:');
- % a
- % b = input('Enter upperbound value:');
- % b
- % str = "exp(1)"
- a=-1;
- b=1;
- a
- b
- h = (b-a)/2;
- x1 = a + h;
- h
- % f = inline(str,'x') ;
- % f = str2func(['@(x) ',str]);
- fa = exp(a) ;
- fb = exp(b) ;
- fx = 4* exp(x1) ;
- I = (h/3)*(fa+fb+fx);
- disp(['Ans: ', num2str(I)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement