0

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

Thanks
pretu

9
Contributors
8
Replies
10
Views
10 Years
Discussion Span
Last Post by jayeshkamble143
0

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

0

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 ...

-1

Hi all
How use sine wave psoc programing in micro controller cy8c27443 code

0

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

Thanks
pretu

You can try Taylor series also.

-1
#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: Added CODE-tags....

Votes + Comments
hijack + obsolete compiler + no code tags => EPIC FAIL
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.