Void main()
{
float fun_random[2][1024];
Gen_random(fun_random);
}
0 |
-14 |
0.02 |
-42 |
0.04 |
-37 |
0.06 |
-42 |
0.08 |
2 |
0.1 |
-33 |
0.12 |
13 |
0.14 |
-23 |
0.16 |
-44 |
0.18 |
0 |
0.2 |
-40 |
0.22 |
15 |
0.24 |
3 |
0.26 |
4 |
0.28 |
-13 |
0.3 |
23 |
0.32 |
-29 |
0.34 |
8 |
0.36 |
-34 |
0.38 |
-47 |
0.4 |
-41 |
0.42 |
2 |
0.44 |
25 |
0.46 |
-27 |
0.48 |
-2 |
0.5 |
-23 |
0.52 |
20 |
0.54 |
-39 |
0.56 |
32 |
0.58 |
4 |
0.6 |
-1 |
0.62 |
-47 |
0.64 |
32 |
0.66 |
-16 |
0.68 |
4 |
0.7 |
-44 |
0.72 |
3 |
0.74 |
-36 |
0.76 |
17 |
0.78 |
40 |
0.8 |
46 |
0.82 |
-14 |
0.84 |
-38 |
0.86 |
32 |
0.88 |
30 |
0.9 |
23 |
0.92 |
17 |
0.94 |
16 |
0.96 |
-30 |
0.98 |
26 |
Прямоугольные импульсы
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <math.h>
#include <fstream>
#include <stdlib.h>
using namespace std;
void Gen_pulse(float fun_pulse[2][1024])
{
int n, i;
double x;
double interval;
double pulse_width, gap_width;
cout << "Число точек: ";
cin >> n;
cout << "Максимальное значение Х: ";
cin >> interval;
cout << "Ширина импульса: ";
cin >> pulse_width;
cout << "Ширина паузы: ";
cin >> gap_width;
double period = pulse_width + gap_width;
for (int i = 0; i < n; i++)
{
x = (interval / n)*i;
fun_pulse[0][i] = x;
double position_in_period = fmod(x, period);
if (position_in_period < pulse_width) {
fun_pulse[1][i] = 1.0;
}
else {
fun_pulse[1][i] = 0.0;
}
}
ofstream out;
out.open("pulse.txt", ios::binary);
if (!out) {
cout << "Не открыт";
}
for (i = 0; i < n; i++)
{
out << fun_pulse[0][i] << ", " << fun_pulse[1][i] << "\n";
}
out.close();
}
Void main()
{
float fun_pulse[2][1024];
Gen_pulse(fun_pulse);
}
0 |
1 |
1 |
1 |
2 |
1 |
3 |
1 |
4 |
1 |
5 |
1 |
6 |
1 |
7 |
1 |
8 |
1 |
9 |
1 |
10 |
1 |
11 |
1 |
12 |
1 |
13 |
1 |
14 |
1 |
15 |
1 |
16 |
1 |
17 |
1 |
18 |
1 |
19 |
1 |
20 |
1 |
21 |
1 |
22 |
1 |
23 |
1 |
24 |
1 |
25 |
0 |
26 |
0 |
27 |
0 |
28 |
0 |
29 |
0 |
30 |
0 |
31 |
0 |
32 |
0 |
33 |
0 |
34 |
0 |
35 |
0 |
36 |
0 |
37 |
0 |
38 |
0 |
39 |
0 |
40 |
0 |
41 |
0 |
42 |
0 |
43 |
0 |
44 |
0 |
45 |
0 |
46 |
0 |
47 |
0 |
48 |
0 |
49 |
0 |
50 |
1 |
51 |
1 |
52 |
1 |
53 |
1 |
54 |
1 |
55 |
1 |
56 |
1 |
57 |
1 |
58 |
1 |
59 |
1 |
60 |
1 |
61 |
1 |
62 |
1 |
63 |
1 |
64 |
1 |
65 |
1 |
66 |
1 |
67 |
1 |
68 |
1 |
69 |
1 |
70 |
1 |
71 |
1 |
72 |
1 |
73 |
1 |
74 |
1 |
75 |
0 |
76 |
0 |
77 |
0 |
78 |
0 |
79 |
0 |
80 |
0 |
81 |
0 |
82 |
0 |
83 |
0 |
84 |
0 |
85 |
0 |
86 |
0 |
87 |
0 |
88 |
0 |
89 |
0 |
90 |
0 |
91 |
0 |
92 |
0 |
93 |
0 |
94 |
0 |
95 |
0 |
96 |
0 |
97 |
0 |
98 |
0 |
99 |
0 |
