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 ...
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
I'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 ...
What's with all the "how to do x without using the obvious x" questions?
http://www.daniweb.com/techtalkforums/thread80025.html
Hi all
How use sine wave psoc programing in micro controller cy8c27443 code
HI All
How can we generate a sine wave without using the sin() function.Thanks
pretu
You can try Taylor series also.
#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;
}
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.