HI All

How can we generate a sine wave without using the sin() function.

Thanks

pretu

Jump to Postyou can use the sine series for calculation upto a certain accuracy and then plot the curve

HI All

How can we generate a sine wave without using the sin() function.Thanks

pretu

Jump to PostI'm assuming you don't want to use the cosine function either :) You could create a table of results and read the values off that instead of using the sine function. Alternatively you could use exponentials and imaginary numbers ...

Jishnu
160
Posting Pro

you can use the sine series for calculation upto a certain accuracy and then plot the curve

HI All

How can we generate a sine wave without using the sin() function.Thanks

pretu

twomers
408
Posting Virtuoso

vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague

Salem
5,138
Posting Sage

http://www.daniweb.com/techtalkforums/thread80025.html

vinai05
0
Newbie Poster

Hi all

How use sine wave psoc programing in micro controller cy8c27443 code

nbaztec
45
Posting Pro in Training

0x69
41
Junior Poster

HI All

How can we generate a sine wave without using the sin() function.Thanks

pretu

You can try Taylor series also.

jayeshkamble143
-4
Newbie Poster

```
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
int main(void)
{
int gdriver = DETECT, gmode;
float x,w1,w,a,f,fs;
cout<<"\n\tEnter amplitude:";
cin>>a;
cout<<"\n\tEnter freq.:";
cin>>f;
cout<<"\n\tEnter sampling points:";
cin>>fs;
w=2*3.14*f;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
line(0, 0,0,500);
line(0,200,800,200);
// getch();
for(int n=0;n<640;n++)
{
w1=w*n;
x=a*sin(w1/fs);
x=x+200;
putpixel(n,x,25);
}
getch();
closegraph();
return 0;
}
```

Edited
by Nick Evan because:
*
Added CODE-tags.... *

Salem
commented:
hijack + obsolete compiler + no code tags => EPIC FAIL
-4

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.

Broken Link

**You're trying to visit a URL that doesn't currently exist on the web.**
Most likely, a member posted a link a long time ago to a web page that has since been removed.
It's also possible that there was a typo when posting the URL.
We redirect you to this notice instead of stripping out the link to preserve the integrity of the post.