Qu

sin

Builtin index · Core maths

result = sin(x)

Input: x · Output: result

What it is

Standard trigonometric functions, computed elementwise. x is the input angle in radians — a scalar, a Vec of any length, or a Mat/Signal of any shape.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = sin(x)
x scalar, Vec, Mat, or Signalnot documented yet
result —
Returns exactly the same type and shape as x, one trig value per element.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

x = 0 to 9
plot(x, sin(x / 2))
output
· plot: figure 10 (10 points)
-1 0 1 2 3 4 5 0 1 2 3 4 5 6 7 8 9 Styled panel

from plotting

x = 0 to 9
plot(x, sin(x / 2), "o")
output
· plot: figure 11 (10 points)
-1 0 1 2 3 4 5 0 1 2 3 4 5 6 7 8 9 x=0, y=0 x=1, y=0.479 x=2, y=0.841 x=3, y=0.997 x=4, y=0.909 x=5, y=0.598 x=6, y=0.141 x=7, y=-0.351 x=8, y=-0.757 x=9, y=-0.978 Styled panel

from plotting

  signal = sin(2 * pi * 10 * (0 to 999) / 1000) + 0.5 * sin(2 * pi * 80 * (0 to 999) / 1000)
  v = vmd(signal, 2)                 # exactly 2 modes

  freqs_hz = v.center_freqs .* fs    # convert to Hz

from numerics-dsp

  k = 0 to 99
  t = 0.02 * k + 0.008 * sin(7 * k)       # uneven sample times

  x = sin(2 * pi * 3 * t)                 # a 3 Hz sinusoid

  power = vanicek(t, x, [1, 3, 5, 8, 12])   # t need not be evenly spaced

from numerics-dsp

See also

cos, tan — documented in the same entry.