Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <cmath>
- #include <fstream>
- int main()
- {
- const double begin = 0.0;
- const double end = 2 * M_PI;
- const double step = 0.0001;
- double c_step = begin;
- double temp = 0.0;
- const int n = 15000; //Number of summed signals
- std::ofstream file;
- file.open("Fourier.csv");
- file << "t" << ";" << "f(x)" << std::endl;
- while (c_step <= end) {
- for (int i = 1; i <= n; i++) {
- temp = temp + 0.5 * (sin((2 * i - 1) * end * c_step)) / (2 * i - 1);
- }
- std::cout << "Progress: " << (c_step / end) * 100 << "%" << std::endl;
- file << c_step << ";" << temp << std::endl;
- c_step += step;
- temp = 0.0;
- }
- file.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement