DOC PREVIEW
CSUN ME 501B - Notes on Symbolic Integration in Matlab

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

College of Engineering and Computer ScienceMechanical Engineering DepartmentNotes on Engineering AnalysisFebruary 1, 2009 Larry CarettoNotes on Symbolic Integration in MatlabDefinite integrals can be evaluated using the symbolic mathematics toolbox of Matlab. This program can provide an algebraic result as well as a numerical value of the result. The required commands and results are shown below. Commands entered by the user follow the “>>” prompt. The remaining text is program output. The initial command, syms x, defines x as a symbolic variable. If you do not use this command, the variable is only treated as a typical variable in a computer program that represents a number. With the syms command you can have the computer do symbolic algebra and calculus for you.The next command in the list below, format long e, sets the appearance of the output to use a large number of significant figures and to be printed in a scientific format.The remaining commands, which are used to find the integralbadxxf )(, have the form int(f(x),a,b), where f(x) is a Matlab string expression for the integrand and a and b are the lower and upper limits respectively. The symbolic expression in the answer, ans, is then evaluated by the command double(ans). For example, the first application of the int function calls for the integration of cos(x/2) between x = –1 and x = 1.1 (Note that Matlab defines the character pair “pi” to refer to . It is not necessary to define this as a symbol.). The result of this command is shown as 4/pi. If the upper and lower limits were not provided, the answer would be shown as 2/pi * sin(pi*x/2).The default variable used to store the result of Matlab commands is ans, short for answer. If is possible to assign the result to another variable by using a command of the form y = int(cos (‘pi*x/2’,-1,1). In this example the answer would start with y = instead of ans =. (Of course, you would first have to use the syms y command to define y as a symbolic variable.)The remaining Matlab commands show below are the commands used to integrate cos(x/2) times even powers of x from the limits of –1 to 1. Once a symbolic result is found the command double(ans) is used to print the numerical value. A command not shown here, pretty(ans), canbe used to improve the appearance of symbolic results.>> syms x>> format long e>> int(cos(pi*x/2),-1,1) ans = 4/pi >> double(ans)1 Matlab typically uses a apostrophe to signify the start and end of string variables. However, for the int command you can enter the string with or without the apostrophes. The commands shownhere do not use them. However, the first integration command could be written as int(cos(pi*x/2,-1,1) or int(cos(‘pi*x/2’,-1,1).Jacaranda (Engineering) Room 3333 Mail Code Phone: 818.677.6448E-mail: lcaretto@csun. 8348 Fax: 818.677.7062ans = 1.273239544735163e+000>> int(x^2*cos(pi*x/2),-1,1) ans = 4*(pi^2-8)/pi^3 >> double(ans)ans = 2.411904428727790e-001>> int(x^4*cos(pi*x/2),-1,1) ans = 4*(pi^4+384-48*pi^2)/pi^5 >> double(ans)ans = 1.002298892908609e-001>> int(x^6*cos(pi*x/2),-1,1) ans = 4*(pi^6+5760*pi^2-120*pi^4-46080)/pi^7 >> double(ans)ans = 5.459022242030317e-002Jacaranda (Engineering) Room 3333 Mail Code Phone: 818.677.6448E-mail: lcaretto@csun. 8348 Fax:


View Full Document

CSUN ME 501B - Notes on Symbolic Integration in Matlab

Download Notes on Symbolic Integration in Matlab
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Notes on Symbolic Integration in Matlab and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Notes on Symbolic Integration in Matlab 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?