Академический Документы
Профессиональный Документы
Культура Документы
Matlab has a powerful symbolic math ability. Rather than making calculations on known numbers, we can make calculations on symbolic expressions. For example, what is the limit as x approaches inf of 1 + 1/2^1 + 1/2^2 + 1/2^3...+1/2^n ? Matlab can tell us. What is the integral of x^3 for any x? Matlab can tell us.
> sr() > qt2 as= n 144 .12 > sr(sm2 ) > qt y() as= n 2(/) ^12 > 2/5 > as= n 04 . > 25+13 > / / as= n 073 .33 > sm2 /sm5 > y() y() as= n 25 / > sm2 /sm5 +sm1 /sm3 > y() y() y() y() as= n 1/5 11
> sm abcx%dfn smoi mt vrals > ys eie yblc ah aibe > f=sm'*^ +bx+c) > y(ax2 * ';
From now on we can use the f symbol to represent the given function.
> f=sm'*^ +bx+c) > y(ax2 * '; > sb(,,) > usfx5 as= n 2 *a+5*b+c 5 > sb(,xabc,5123) > usf[ ][ ] as= n 3 8
> y=snx > i() y= snx i() > epo() > zlty
Now try:
> f=snx; > i() > g=csy; > o() > esr(+) > zuffg;
Or really cool!
> epo(,[-,1 ]; %fo - <x<1 > zlty 5 0 ) rm 5 0 > esr(,[ 2 [ 7) %xfo 1t 2 yfo 5t 7 > zufz[1 ] 5 ]; rm o , rm o
> f=sm'*^ +bx+c) > y(ax2 * '; > epo(usf[ bc,123); > zltsb(,a ][ ])
Differentiation
> sm x > ys ; f=sn5x i(*) > f= > sn5x i(*) >df() >iff as= n 5cs5x *o(*)
2nd Derivative
To take the 2nd (or greater) derivative of an equation, we use:
> f=x3 > ^ f= x3 ^ > df()%1tdrvtv > iff s eiaie as= n 3x2 *^ > df(,)%2ddrvtv > iff2 n eiaie as= n 6x * > df(,)%3ddrvtv > iff3 r eiaie as= n 6 > df(,)%4hdrvtv > iff4 t eiaie as= n 0
> sm xt > ys ; f=sn x*t) i( >df(,) %drvtv o fwt rsett t >ifft eiaie f ih epc o as= n csxt* o(*)t
Integration
By using the "int" function, in the same way we use the diff function, we can ask Matlab to do symbolic integration for us.
Warning: Do not confuse the int function in Matlab with the integer (int) data type in C or the int8, int16, int32 data types in Matlab.
Definite Integrals
As you (should) know, a definite integral represents the area under a curve from a given start point to a given end point. What if we want to know how much area is under the curve f(x) = x^3; from 0 to 10, from -10 to 10, from -10 to 0?
> itx301) > n(^,,0 as= n 20 50 > itx3-01) > n(^,1,0 as= n 0 > itx3-00 > n(^,1,) as= n -50 20
Summations
You can use Matlab to tell you the sum of a series of equations, such as: 1 + 1/2^2 + 1/3^2 + 1/4^2 + ... + 1/N^2 From N = 1 to inf (or from value1 to value2)
Mathematical Limits
Every wonder what happens if you divide infinity by infinity? Well depending on how those values were created, you can get some interesting results. For example, what is the limit of x/ x*x as X approaches infinity?
> lmt 1/x) %wt n prm,b dfnto,a xapoce 0 > ii( ih o aas y eiiin s prahs as= n NN a > lmtx/x2 if %a xapoce if > ii( ^, n) s prahs n as= n 0 > lmtsnx /x %a xapoce 0 > ii(i() ) s prahs as= n ?? ??
Expand Function
The expand function will "expand" a formula by doing basic symbolic math where possible.
sm x ys ; > f =(+)(+) > 1 x5*x5; f = 1 (+)2 x5^ > epn(1 > xadf) as= n x21*+5 ^+0x2
Simplify Function
When you have a complex evaluated symbolicexpression, such as: (sin(x)^2 + cos(x)^2), you can use the simplify function to ask matlab to try and simplify it to a less complex term:
f=snx^ +csx^; i()2 o()2 pet(f) rty 2 2 snx +csx i() o()
"Taylor" Command
If you would like to create a taylor series, you can use the "taylor" function.
it'*^+*^+*+' n(Ax3Bx2CxD) Wrig Epii itga cudntb fud ann: xlct nerl ol o e on. as= n
itCx+Ax3+Bx2+D x n(* *^ *^ , ) %BT U sm ABCDx ys itAx3Bx2CxD n(*^+*^+*+) as= n (*^)4+(*^)3+(*^)2+Dx Ax4/ Bx3/ Cx2/ *
To fix this problem, append an _ (underscore) to the variable The following symbols are known