Many students ask me how do I do this or that in MATLAB. So I thought why not have a small series of my next few blogs do that. In this blog I show you how to integrate a continuous function.
The MATLAB program link is here.
The HTML version of the MATLAB program is here.
%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB. Most of the questions relate to a mathematical
% How do I integrate a continuous function?
% Language : Matlab 2008a;
% Authors : Autar Kaw;
% Mfile available at
% Last Revised : March 28, 2009;
% Abstract: This program shows you how to integrate a given function.
disp(‘ This program shows you how to integrate’)
disp(‘ a given function ‘)
disp(‘ Autar K Kaw of http://autarkaw.wordpress.com’)
disp(‘ March 29, 2009’)
% Integrate exp(x)*sin(3*x) from x=2.0 to 8.7
% Define x as a symbol
% Assigning the function to be differentiated
% Assigning the lower limit
% Assigning the upper limit
%% DISPLAYING INPUTS
func=[‘ The function is to be integrated is ‘ char(y)];
fprintf(‘ Lower limit of integration, a= %g’,a)
fprintf(‘\n Upper limit of integration, b= %g’,b)
%% THE CODE
% Finding the integral using the int command
% Argument 1 is the function to be integrated
% Argument 2 is the variable with respect to which the
% function is to be integrated – the dummy variable
% Argument 3 is the lower limit of integration
% Argument 4 is the upper imit of integration
%% DISPLAYING OUTPUTS
fprintf(‘ Value of integral is = %g’,intvalue)
This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://nm.mathforcollege.com/videos and http://www.youtube.com/numericalmethodsguy