Activity 1.3.
How do you find the sine of an angle in MATLAB,
-
where the angle is given in radians (for example, \(sin(\frac{\pi}{6})\))?
-
where the angle is given in degrees (for example, \(sin(30\deg)\))?
sqrt(x)exp(x)abs(x)log(x)log10(x)factorial(n)sin(x)cos(x)tan(x)cot(x)asin(x)acos(x)atan(x)acot(x)sinh(x)cosh(x)tanh(x)coth(x)dto any of the above function names will produce results in degrees, i.e.sind(x)
| Function | Description | Example |
round(x) |
round to the nearest integer \((.5 \leq x \lt 1.5 = 1)\)
|
>> round(17/5) ans = 3 |
fix(x) |
round towards zero (truncate)
|
>> fix(13/5) ans = 2 |
ceil(x) |
round towards infinity (like fix for x < 0)
|
>> ceil(11/5) ans = 3 |
floor(x) |
round towards minus infinity (like fix for x > 0)
|
>> floor(-9/4) ans = -3 |
rem(x,y) |
remainder after x is divided by y
|
>> rem(13,5) ans = 3 |
sign(x) |
1 if x > 0, -1 if x < 0, and 0 if x = 0
|
>> sign(5) ans = 1 |