02.03.2016 Views

MATLAB by rudra pratap

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.8 Lesson 8: Symbolic Computation<br />

49<br />

Define a column vector v = [X yf.<br />

Find the inner product vTv. Note<br />

that <strong>MATLAB</strong> assumes x and y to<br />

be complex (default data type)<br />

x*conj (x) +<br />

variables and hence<br />

VT 7! = XX + yf} .<br />

>> ·<br />

>> inner<br />

inner _product<br />

XA2 + yA2<br />

be real and evaluate the inner<br />

product.<br />

Since x and y are real,<br />

v T v = x2 + y2 .<br />

>> syms a b<br />

>> expl 1a*x + b *y - 3 I ;<br />

>> exp2 I -x<br />

+ 2*a*y -5 I ;<br />

>> [x, y]<br />

= solve (expl , exp2 )<br />

Solve two simultaneous algebraic<br />

equations for x and y:<br />

ax +<strong>by</strong> - 3 0<br />

-x + 2ay - 5 0<br />

X =<br />

(6*a - 5*b) / (2* aA2 + b)<br />

y =<br />

(5*a + 3) / (2*aA2 + b)<br />

>> sub s(exp l)<br />

ans =<br />

Substitute the values of x and y just<br />

found in expl to check the result.<br />

( b* (S*a + 3) )/(2*a A 2 + b) + ( a* (6*a - 5*b) ) / (2*aA2 + b) -3<br />

>> s i mp lify (ans)<br />

ans<br />

0<br />

Simplify the answer to see if it<br />

reduces to zero (as it must in order<br />

to satisfy the equation).<br />

>> pretty (subs ( exp2 ))<br />

2 a (5 a + 3) 6 a - 5 b<br />

Use pretty to get the expression in<br />

more readable form.<br />

------------- - --------- - 5<br />

2<br />

2 a + b 2 · a<br />

Figure 2.11: LesRon 8: Symbolic calculations.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!