正在加载图片...
ATLAB Lecture 5 School of Mathematical Sciences Xiamen University http∥gdjpkc.xmu.edu.cr 14142 >>a=sqrt(sym(2)) %using symbolic notation for the square root operation MATLAB gives the result 2(112), which means √2, without actually calculating a numerical value. MATLAB records this symbolic expression in the string that represents 2(1/2). You can always obtain the numerical value of a symbolic object with the double > double(a) ans 14142 Notice that the result is indented, which tells you it has data type double. Symbolic results are not indented When you create a fraction involving symbolic objects, MATLAB records the numerator and > sym(2)/sym(5)+sym( 1)/sym(3) %performs arithmetic on symbolic objects ll/15 >>2/5+1/3 %gives the answer as a decimal fraction 0.7333 The Symbolic Math Toolbox enables you to perform a variety of symbolic calculations that arise in mathematics and science Y Creating Symbolic Variables and Expressions >>x=sym('x): %construct symbolic variable >>a=sym(alpha+2): %construct symbolic expression >>rho= sym((1 sqrt(5))/2); %use a symbolic variable to represent the golden ratio >>fl= rho- rho-1 f (1/2+12*5^(1/2)2-3/2-12*5^(1/2) >>eval(fl) %evaluate fl >>f2=sym(a*x2+bx+c) assigns the symbolic expression to the variable f2 To perform symbolic math operations(e.g, Integration, differentiation, substitution, etc. )on t2, you need to create the variables explicitly. A better alternative is to enter the command >>a=sym('a), b= sym():c=sym('c):x=sym('x)MATLAB Lecture 5  School of Mathematical Sciences Xiamen University  http://gdjpkc.xmu.edu.cn  Lec5­2  1.4142  >> a = sqrt(sym(2)) %using symbolic notation for the square root operation  a =  2^(1/2) MATLAB gives  the result  2^(1/2),  which means  2 ,  without  actually calculating a numerical  value.  MATLAB records this symbolic expression  in the string that  represents 2^(1/2). You can always  obtain the numerical  value of a symbolic object  with the double command:  >> double(a) ans =  1.4142  Notice that the result is indented, which tells you it has data type double. Symbolic results are not indented.  When you create a fraction involving symbolic objects, MATLAB records the numerator and  denominator. For example:  >> sym(2)/sym(5)+sym(1)/sym(3) %performs arithmetic on symbolic objects ans =  11/15  >> 2/5 + 1/3  %gives the answer as a decimal fraction  ans =  0.7333  The Symbolic Math Toolbox enables you to perform a variety of symbolic calculations that  arise in mathematics and science.  ² Creating Symbolic Variables and Expressions >> x = sym('x');  %construct symbolic variable >> a = sym('alpha+2');  %construct symbolic expression  >> rho = sym('(1 + sqrt(5))/2');  %use a symbolic variable to represent the golden ratio  >> f1 = rho^2 ­ rho ­ 1  f1 =  (1/2+1/2*5^(1/2))^2­3/2­1/2*5^(1/2) >> eval(f1) %evaluate f1  ans =  0  >> f2 = sym('a*x^2 + b*x + c') % assigns the symbolic expression to the variable f2  To perform symbolic math operations (e.g., integration, differentiation, substitution, etc.) on  f2, you need to create the variables explicitly. A better alternative is to enter the commands  >> a = sym('a'); b = sym('b'); c = sym('c'); x = sym('x') or simply
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有