Search code examples
cmatlabmathdigitaltrigonometry

Sine function in Matlab/C/Java or any other program in digital systems


How does Matlab/C generates Sine wave, I mean do they store the values for every angle ? but if they do then there are infinite values that are needed to be stored.


Solution

  • There are many, many routines for calculating sines of angles using only the basic arithmetic operators available on any modern digital computer. One such, but only one example, is the CORDIC algorithm. I don't know what algorithm(s) Matlab uses for trigonometric functions.

    Computers don't simply look up the value of a trigonometric function in a stored table of values, though some of the algorithms in current use do look up critical values in stored tables. What those tables contain is algorithm-specific and would probably not accord with a naive expectation of a trig table.

    Note that this question has been asked many times on SO, this answer seems to be the pick of them.