Presentation is loading. Please wait.

Presentation is loading. Please wait.

DSP Lab. Week 1 Drawing sinusoidal waves

Similar presentations


Presentation on theme: "DSP Lab. Week 1 Drawing sinusoidal waves"— Presentation transcript:

1 DSP Lab. Week 1 Drawing sinusoidal waves
Doug Young Suh Media Lab. Rm401 Last update : September 8, 2015

2 MediaLab , Kyunghee University
Sinusoidal wave MediaLab , Kyunghee University

3 MediaLab , Kyunghee University
C-program #include <stdio.h> #include <conio.h> #include <math.h> main() { FILE *data = fopen("data.txt","w"); for(int i=0;i<1000;i++) fprintf(data,"%4d %10.2f\n",i, *sin(2.*3.14/100*(float)i)+40.*sin(2.*3.14/300*(float)i)); fclose(data); data = fopen("data440.txt","w"); for(i=0;i<4000;i++) fprintf(data,"%4d %10.2f\n",i,sin(2.*3.14*440.0/ *(float)i)); } MediaLab , Kyunghee University

4 MediaLab , Kyunghee University
C++ program #include <iostream> //이 코드에서는 fstream만 사용하므로 iostream은 생략해도 됩니다. #include <fstream> #include <iomanip> #include <math.h> //math.h대신 cmath 써도 됩니다. using namespace std; int main() { ofstream outFile; outFile.open("data.txt", ios::out|ios::trunc); // ios::trunc로 덮어쓰기 파일 설정. for (int i = 0; i < 1000; i++) { outFile << i << " " << *sin(2.*3.14 / 100 * (float)i) + 40.*sin(2.*3.14 / 300 * (float)i) << endl; } outFile.close(); outFile.open("data440.txt", ios::out|ios::trunc); for (int i = 0; i < 1000; i++) { outFile << i << " " << sin(2.*3.14*440.0 / *(float)i) << endl; } outFile.close(); return 0; } MediaLab , Kyunghee University

5 MediaLab , Kyunghee University
Assignments Send to MediaLab , Kyunghee University


Download ppt "DSP Lab. Week 1 Drawing sinusoidal waves"

Similar presentations


Ads by Google