Professional Documents
Culture Documents
Звіт Лаб 15
Звіт Лаб 15
Факультет електроніки
та комп’ютерних технологій
Звіт
Виконав:
Корпан Денис
Перевірив:
Львів-2020
Завдання: Удосконалити проект «Розкладення періодичної функції у ряд
Фур’є» у середовищі VC++, шляхом додавання у проект можливості
записування у бінарний файл результатів, які обчислювались у попередній
роботі (Лаб. роб. 14) для побудови графіків функцій і візуалізації амплітудного
спектру періодичної функції.
namespace Lab15 {
struct Zapys
double Xe[1000];
double Ye[1000];
double Yg[1000];
double c[50];
};
Zapys F_GRF;
/// <summary>
public:
MyForm(void)
InitializeComponent();
//
//
protected:
/// <summary>
/// </summary>
~MyForm()
if (components)
delete components;
protected:
private:
/// <summary>
/// </summary>
System::ComponentModel::Container ^components;
/// <summary>
/// </summary>
void InitializeComponent(void)
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>pictureBox1))->BeginInit();
this->groupBox1->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown4))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown3))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown2))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown1))->BeginInit();
this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
//
// groupBox1
//
this->groupBox1->Controls->Add(this->button3);
this->groupBox1->Controls->Add(this->button2);
this->groupBox1->Controls->Add(this->button1);
this->groupBox1->Controls->Add(this->numericUpDown4);
this->groupBox1->Controls->Add(this->numericUpDown3);
this->groupBox1->Controls->Add(this->numericUpDown2);
this->groupBox1->Controls->Add(this->numericUpDown1);
this->groupBox1->Controls->Add(this->textBox4);
this->groupBox1->Controls->Add(this->textBox3);
this->groupBox1->Controls->Add(this->textBox2);
this->groupBox1->Controls->Add(this->textBox1);
this->groupBox1->Controls->Add(this->label11);
this->groupBox1->Controls->Add(this->label10);
this->groupBox1->Controls->Add(this->label9);
this->groupBox1->Controls->Add(this->label8);
this->groupBox1->Controls->Add(this->label7);
this->groupBox1->Controls->Add(this->label6);
this->groupBox1->Controls->Add(this->label5);
this->groupBox1->Controls->Add(this->label4);
this->groupBox1->Controls->Add(this->label3);
this->groupBox1->Controls->Add(this->label2);
this->groupBox1->Controls->Add(this->label1);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->TabIndex = 1;
this->groupBox1->TabStop = false;
//
// button3
//
this->button3->Name = L"button3";
this->button3->TabIndex = 21;
this->button3->UseVisualStyleBackColor = true;
//
// button2
//
this->button2->Name = L"button2";
this->button2->TabIndex = 20;
this->button2->Text = L"Вихід";
this->button2->UseVisualStyleBackColor = true;
//
// button1
//
this->button1->Name = L"button1";
this->button1->TabIndex = 19;
this->button1->UseVisualStyleBackColor = true;
//
// numericUpDown4
//
this->numericUpDown4->Name = L"numericUpDown4";
this->numericUpDown4->TabIndex = 18;
//
// numericUpDown3
//
this->numericUpDown3->Name = L"numericUpDown3";
this->numericUpDown3->TabIndex = 17;
//
// numericUpDown2
//
this->numericUpDown2->Name = L"numericUpDown2";
this->numericUpDown2->TabIndex = 16;
//
// numericUpDown1
//
this->numericUpDown1->Location = System::Drawing::Point(541, 69);
this->numericUpDown1->Name = L"numericUpDown1";
this->numericUpDown1->TabIndex = 15;
//
// textBox4
//
this->textBox4->Name = L"textBox4";
this->textBox4->TabIndex = 14;
//
// textBox3
//
this->textBox3->Name = L"textBox3";
this->textBox3->TabIndex = 13;
//
// textBox2
//
this->textBox2->Name = L"textBox2";
this->textBox2->TabIndex = 12;
//
// textBox1
//
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(100, 22);
this->textBox1->TabIndex = 11;
//
// label11
//
this->label11->AutoSize = true;
this->label11->Name = L"label11";
this->label11->TabIndex = 10;
//
// label10
//
this->label10->AutoSize = true;
this->label10->Name = L"label10";
this->label10->TabIndex = 9;
this->label10->Text = L"Ne=";
//
// label9
//
this->label9->AutoSize = true;
this->label9->Name = L"label9";
this->label9->TabIndex = 8;
//
// label8
//
this->label8->AutoSize = true;
this->label8->TabIndex = 7;
//
// label7
//
this->label7->AutoSize = true;
this->label7->Name = L"label7";
this->label7->TabIndex = 6;
//
// label6
//
this->label6->AutoSize = true;
this->label6->Name = L"label6";
this->label6->TabIndex = 5;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Name = L"label5";
this->label5->TabIndex = 4;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Name = L"label4";
this->label4->TabIndex = 3;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Name = L"label3";
this->label3->TabIndex = 2;
this->label3->Text = L"bl=";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Name = L"label2";
this->label2->TabIndex = 1;
this->label2->Text = L"al=";
//
// label1
//
this->label1->AutoSize = true;
this->label1->Name = L"label1";
this->label1->TabIndex = 0;
//
// MyForm
//
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->pictureBox1);
this->Name = L"MyForm";
this->Text = L"MyForm";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>pictureBox1))->EndInit();
this->groupBox1->ResumeLayout(false);
this->groupBox1->PerformLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown4))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown3))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown2))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown1))->EndInit();
this->ResumeLayout(false);
#pragma endregion
double f(double x)
else
double h;
int i;
Xe[0] = F_GRF.al;
Ye[i] = f(Xe[i]);
Xe[i + 1] = Xe[i] + h;
void Furje(double Xe[1000], double Ye[1000], int Ne, double Yg[1000], double c[50],
double TP)
double a[50];
double b[50];
int i, k;
double w, KOM, S, G, D;
F_GRF.Ng = Convert::ToInt32(textBox2->Text);
F_GRF.al = Convert::ToDouble(textBox3->Text);
F_GRF.bl = Convert::ToDouble(textBox4->Text);
w = 6.2831853 / F_GRF.Tp;
KOM = k * w;
G = 0.0;
D = 0.0;
{
S = KOM * Xe[i];
G = G + Ye[i] * Math::Cos(S);
D = D + Ye[i] * Math::Sin(S);
a[k] = 2 * G / Ne;
b[k] = 2 * D / Ne;
a[0] = 0.0;
S = 0;
D = Xe[i] * w;
KOM = k * D;
Yg[i] = a[0] + S;
return;
int i, KrokXG, x;
Graphics^ g = pictureBox1->CreateGraphics();
MaxC = c[1];
x = KrokXG + 20;
x = x + KrokXG;
x = KrokXG + 19;
int i;
Graphics^ g = pictureBox1->CreateGraphics();
g->Clear(Color::White);
F_GRF.L = 40;
F_GRF.Ne = Convert::ToInt32(textBox1->Text);
F_GRF.al = Convert::ToDouble(textBox3->Text);
F_GRF.bl = Convert::ToDouble(textBox4->Text);
F_GRF.Ngr = F_GRF.Ne;
TabF(F_GRF.Xe, F_GRF.Ye);
F_GRF.minYg = F_GRF.Yg[0];
F_GRF.maxYg = F_GRF.Yg[0];
F_GRF.minx = F_GRF.Xe[0];
F_GRF.miny = F_GRF.Ye[0];
F_GRF.maxy = F_GRF.Ye[0];
binout.write((char*)&F_GRF, sizeof(Zapys));
Close();
int i;
Graphics^ g = pictureBox1->CreateGraphics();
g->Clear(Color::White);
int pb_Height = pictureBox1->Height;
bincin.read((char*)&F_GRF, sizeof(Zapys));
bincin.close();
//закриття бінарного файлу
if (F_GRF.minx * F_GRF.maxx > 0.0 && F_GRF.minx < 0.0) F_GRF.Gx = F_GRF.maxx;
if (F_GRF.miny * F_GRF.maxy > 0.0 && F_GRF.miny > 0.0) F_GRF.Gy = F_GRF.miny;
if (F_GRF.miny * F_GRF.maxy > 0.0 && F_GRF.miny < 0.0) F_GRF.Gy = F_GRF.maxy;
F_GRF.xx = F_GRF.minx;
F_GRF.yy = F_GRF.maxy;
g->Clear(Color::White);
Garm(F_GRF.Ng, F_GRF.c);
};
Результати:
Висновок: Виконуючи лабораторну роботу я навчився додавати у проект
можливість записувати результати у бінарний файл. З домогою цього,
запускаючи програму наступного разу не вводячи данних я отримую графік,
побудований за данними, які були записані у бінарний файл.