Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
1. Моедлирование сигналов / Лабораторная 1. Моделирование сигналов. Агеев.docx
Скачиваний:
1
Добавлен:
16.12.2025
Размер:
73.13 Кб
Скачать

Void Gen_sin(float fun_sin[2][1024])

{

int n, i;

double x;

double pi = 3.14;

cout << "Число точек: ";

cin >> n;

for (int i = 0; i < n; i++)

{

x = (100.0/n)*i;

fun_sin[0][i] = x;

if (x <= 50.0) {

double scaled_x = x*(10.0*pi / 50.0);

fun_sin[1][i] = sin(scaled_x);

}

else {

fun_sin[1][i]=0.0

}

}

ofstream out;

out.open("radio.txt", ios::binary);

if (!out) {

cout << "Не открыт";

}

for (i = 0; i < n; i++)

{

out << fun_sin[0][i] << ", " << fun_sin[1][i] << "\n";

}

out.close();

}

Void main()

{

float fun_sin[2][1024];

Gen_sin(fun_sin);

}

0

0

1

0,587528

2

0,950859

3

0,951351

4

0,588816

5

0,00159265

6

-0,586238

7

-0,950365

8

-0,951841

9

-0,590102

10

-0,0031853

11

0,584947

12

0,949868

13

0,952328

14

0,591387

15

0,00477794

16

-0,583654

17

-0,949369

18

-0,952813

19

-0,592671

20

-0,00637057

21

0,582361

22

0,948868

23

0,953295

24

0,593953

25

0,00796318

26

-0,581065

27

-0,948364

28

-0,953775

29

-0,595233

30

-0,00955578

31

0,579768

32

0,947857

33

0,954252

34

0,596512

35

0,0111483

36

-0,57847

37

-0,947349

38

-0,954727

39

-0,59779

40

-0,0127409

41

0,57717

42

0,946837

43

0,9552

44

0,599066

45

0,0143334

46

-0,575869

47

-0,946324

48

-0,95567

49

-0,60034

50

-0,0159259

51

0

52

0

53

0

54

0

55

0

56

0

57

0

58

0

59

0

60

0

61

0

62

0

63

0

64

0

65

0

66

0

67

0

68

0

69

0

70

0

71

0

72

0

73

0

74

0

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

Случайный сигнал

#include "stdafx.h"

#include <iostream>

#include <windows.h>

#include <math.h>

#include <fstream>

#include <stdlib.h>

#include <time.h>

using namespace std;

void Gen_random(float fun_random[2][1024])

{

int n, i;

double x;

int min_amplitude, max_amplitude;

srand(time(NULL));

cout << "Число точек: ";

cin >> n;

cout << "Минимальное значение амплитуды: ";

cin >> min_amplitude;

max_amplitude = min_amplitude + 100;

cout << "Диапазон амплитуды: от " << min_amplitude << " до " << max_amplitude << endl;

for (int i = 0; i < n; i++)

{

x = (1.0 / n)*i;

fun_random[0][i] = x;

fun_random[1][i] = min_amplitude + (rand() % 101);

}

ofstream out;

out.open("random.txt", ios::binary);

if (!out) {

cout << "Не открыт";

}

for (i = 0; i < n; i++)

{

out << fun_random[0][i] << ", " << fun_random[1][i] << "\n";

}

out.close();

}

Соседние файлы в папке 1. Моедлирование сигналов