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.1 Lesson 1: A Minimum MATLAD Session<br />

19<br />

EXERCISES<br />

1. Arithmetic operations: Compute the following quantities:<br />

• 2;1 and compare with (1 - .Js )-1.<br />

• 3 (jl;12 - 1. The square root Vx can be calculated with the command<br />

sqrt (x) or x-o . 5.<br />

• Area = 1rr 2 with r = 1r - 1. (1r is pi in <strong>MATLAB</strong>.)<br />

2. Exponential and logarithms: The mathematical quantities ex, ln x, and<br />

log x are calculated with exp (x) , log (x) , and log10 (x) , respectively. Calculate<br />

the following quantities:<br />

• e3 , ln(e 3), log10(e3), and log10(10 5 ).<br />

• e"VI63.<br />

• Solve 3x = 17 for x and check the result. (The solution is x = 1f,/37<br />

can verify the result <strong>by</strong> direct substitution.)<br />

. You<br />

3. Trigonometry: The basic <strong>MATLAB</strong> trigonometric functions are sin, cos ,<br />

tan, cot , sec, and esc. The inverses, e.g., arcsin, arctan, etc., are call:ulated<br />

with as in, a tan, etc. The same is true for hyperbolic functions.<br />

The inverse function atan2 takes two arguments, y and x, and gives the fourquadrant<br />

inverse tangent. The argument of these functions must be in radians.<br />

Calculate the following quantities:<br />

• sin ' cos 1r, and tan ·<br />

• sin 2 + cos 2 · (Typing sin-2(x) for sin 2 x will produce an error).<br />

• y = cosh 2 x -sinh 2 x, with x = 327r.<br />

4. Complex numbers: <strong>MATLAB</strong> recognizes the letters i and j as the imaginary<br />

number A. A complex number 2 + 5i may be input as 2+5i or 2+5*i<br />

in <strong>MATLAB</strong>. The former case is always interpreted as a complex number,<br />

whereat; the latter case is taken as complex only if i has not been assigned<br />

auy local value. The same is true for j. This kind of context dependence, for<br />

better or worse, pervades <strong>MATLAB</strong>. Compute the following quantities:<br />

• i:+:!. Can you check the result <strong>by</strong> hand calculation?<br />

• c; . Check the Euler's Formula e i x = cos x + i sin x <strong>by</strong> computing the<br />

right-haml t;iue too, i.e., compute cot>(7r/4) + ·i sin(7r/4).<br />

• Exet.:ule the commands exp (pi/2*i) and exp (pi/2i). Can you explain<br />

the difference between the two results?

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

Saved successfully!

Ooh no, something went wrong!