Построение графика функции

Автор: Пользователь скрыл имя, 21 Января 2013 в 21:40, лабораторная работа

Краткое описание

Цель работы: построить график функции в среде разработки Visual Basic.NET.
Будем считать, что на рынке одного товара функция спроса и функция предложения – линейные функции цены на момент времени или цены предыдущего момента времени.
Составить программу, которая:
1. Изображает кривую спроса и кривую предложения на плоскости, по оси абсцисс которой отложена цена , а по оси ординат – количество сделок.
2. Вычисляет начальное предложение исходя из начального значения цены на момент времени .
3. Изображает маршрут "изменение цены → изменение числа сделок", который имеет вид "паутины", повторив несколько раз процессы.

Файлы: 25 файлов

Документ Microsoft Wordистория.docx

— 17.42 Кб (Открыть, Скачать)

ВВОДНИК.doc

— 326.00 Кб (Открыть, Скачать)

код на 3 лабу по модел экон.docx

— 491.37 Кб (Скачать)

Imports System.Math

Public Class Form1

    Inherits System.Windows.Forms.Form

    Public Sub построение_графика(ByVal sinX(,) As Single, ByVal sinY(,) As Single, ByVal кол_во_ГРАФИКОВ As Integer, ByVal подпись_Y As String, ByVal подпись_Х As String)

        Dim xmin, xmax, ymax, ymin As Single

        Dim высота_граф, ширина_граф As Single

        Dim i As Integer = 0

        Dim g As Graphics = PB.CreateGraphics

        Dim j As Integer

        g.Clear(Color.White)

        'Me.Refresh()

        xmin = 0 : xmax = 0

        For i = 1 To кол_во_ГРАФИКОВ

            For j = 0 To 100

                If xmin > sinX(i, j) Then : xmin = sinX(i, j)

                End If

                If xmax < sinX(i, j) Then : xmax = sinX(i, j)

                End If

                If ymin > sinY(i, j) Then : ymin = sinY(i, j)

                End If

                If ymax < sinY(i, j) Then : ymax = sinY(i, j)

                End If

            Next

        Next

        высота_граф = PB.Height - 120 : ширина_граф = PB.Width - 100 - 40

 

        g.DrawLine(Pens.Black, 50, высота_граф + 50, 50 + ширина_граф + 30, высота_граф + 50)

        g.DrawLine(Pens.Black, 50 + ширина_граф + 20, высота_граф + 45, 50 + ширина_граф + 30, высота_граф + 50)

        g.DrawLine(Pens.Black, 50 + ширина_граф + 20, высота_граф + 55, 50 + ширина_граф + 30, высота_граф + 50) ' ось Х

 

        g.DrawLine(Pens.Black, 50, высота_граф + 50, 50, 30)

        g.DrawLine(Pens.Black, 45, 40, 50, 30)

        g.DrawLine(Pens.Black, 55, 40, 50, 30) ' ось У

        For i = 1 To кол_во_ГРАФИКОВ

            For j = 1 To 100

                If sinY(i, j) = 0 Then

                    Exit For

                End If

                g.DrawLine(Pens.Green, 50 + Abs(sinY(i, j - 1) - ymin) * (ширина_граф / (ymax - ymin)), _

                50 + высота_граф - Abs(sinX(i, j - 1) - xmin) * (высота_граф / (xmax - xmin)), _

                50 + Abs(sinY(i, j) - ymin) * (ширина_граф / (ymax - ymin)), _

                50 + высота_граф - Abs(sinX(i, j) - xmin) * (высота_граф / (xmax - xmin)))

            Next

        Next

        Dim myFont = New Font("Arial", 12, FontStyle.Bold)

        Dim myFont1 = New Font("Arial", 8, FontStyle.Regular)

        Dim myBrush = New SolidBrush(Color.Black)

        ' вывод значений графика

        g.DrawString(подпись_Х, myFont, myBrush, 10, 20)

        g.DrawString(подпись_Y, myFont, myBrush, 50 + ширина_граф + 20, высота_граф + 50)

        Dim шаг_для_надписей_по_высоте, шаг_для_надписей_по_горизонтали As Single

        For i = 0 To 10

            шаг_для_надписей_по_высоте = 50 + высота_граф - высота_граф / 10 * i

            g.DrawString(Format(CStr((xmax - xmin) / 10 * i), "Fixed"), myFont1, myBrush, 3, шаг_для_надписей_по_высоте - 10)

            g.DrawLine(Pens.Red, 45, шаг_для_надписей_по_высоте, 55, шаг_для_надписей_по_высоте)

 

            шаг_для_надписей_по_горизонтали = 50 + (ширина_граф) / 10 * i

            g.DrawLine(Pens.Red, шаг_для_надписей_по_горизонтали, 50 + высота_граф - 5, шаг_для_надписей_по_горизонтали, 50 + высота_граф + 5)

            g.DrawString(Format(CStr((ymax - ymin) / 10 * i), "Fixed"), myFont1, myBrush, шаг_для_надписей_по_горизонтали  - 10, 50 + высота_граф + 15)

 

        Next

    End Sub

 

    Dim xn, xsh, xl As Single

    Public SinX(100, 100), sinY(100, 100) As Single

#Region " Windows Form Designer generated code "

 

    Public Sub New()

        MyBase.New()

 

        'This call is required by the Windows Form Designer.

        InitializeComponent()

 

        'Add any initialization after the InitializeComponent() call

 

    End Sub

 

    'Form overrides dispose to clean up the component list.

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

        If disposing Then

            If Not (components Is Nothing) Then

                components.Dispose()

            End If

        End If

        MyBase.Dispose(disposing)

    End Sub

 

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

 

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer. 

    'Do not modify it using the code editor.

    Friend WithEvents PB As System.Windows.Forms.PictureBox

    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox

    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox

    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox

    Friend WithEvents TextBox4 As System.Windows.Forms.TextBox

    Friend WithEvents TextBox5 As System.Windows.Forms.TextBox

    Friend WithEvents Button1 As System.Windows.Forms.Button

    Friend WithEvents Button2 As System.Windows.Forms.Button

    Friend WithEvents Button3 As System.Windows.Forms.Button

    Friend WithEvents Button4 As System.Windows.Forms.Button

    Friend WithEvents Label1 As System.Windows.Forms.Label

    Friend WithEvents Button5 As System.Windows.Forms.Button

    Friend WithEvents Label2 As System.Windows.Forms.Label

    Friend WithEvents Label3 As System.Windows.Forms.Label

    Friend WithEvents Label4 As System.Windows.Forms.Label

    Friend WithEvents Label5 As System.Windows.Forms.Label

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        Me.PB = New System.Windows.Forms.PictureBox

        Me.GroupBox1 = New System.Windows.Forms.GroupBox

        Me.Label5 = New System.Windows.Forms.Label

        Me.Label4 = New System.Windows.Forms.Label

        Me.Label3 = New System.Windows.Forms.Label

        Me.Label2 = New System.Windows.Forms.Label

        Me.Label1 = New System.Windows.Forms.Label

        Me.TextBox5 = New System.Windows.Forms.TextBox

        Me.TextBox4 = New System.Windows.Forms.TextBox

        Me.TextBox3 = New System.Windows.Forms.TextBox

        Me.TextBox2 = New System.Windows.Forms.TextBox

        Me.TextBox1 = New System.Windows.Forms.TextBox

        Me.Button1 = New System.Windows.Forms.Button

        Me.Button2 = New System.Windows.Forms.Button

        Me.Button3 = New System.Windows.Forms.Button

        Me.Button4 = New System.Windows.Forms.Button

        Me.Button5 = New System.Windows.Forms.Button

        Me.GroupBox1.SuspendLayout()

        Me.SuspendLayout()

        '

        'PB

        '

        Me.PB.Location = New System.Drawing.Point(24, 40)

        Me.PB.Name = "PB"

        Me.PB.Size = New System.Drawing.Size(568, 432)

        Me.PB.TabIndex = 0

        Me.PB.TabStop = False

        '

        'GroupBox1

        '

        Me.GroupBox1.Controls.Add(Me.Label5)

        Me.GroupBox1.Controls.Add(Me.Label4)

        Me.GroupBox1.Controls.Add(Me.Label3)

        Me.GroupBox1.Controls.Add(Me.Label2)

        Me.GroupBox1.Controls.Add(Me.Label1)

        Me.GroupBox1.Controls.Add(Me.TextBox5)

        Me.GroupBox1.Controls.Add(Me.TextBox4)

        Me.GroupBox1.Controls.Add(Me.TextBox3)

        Me.GroupBox1.Controls.Add(Me.TextBox2)

        Me.GroupBox1.Controls.Add(Me.TextBox1)

        Me.GroupBox1.Location = New System.Drawing.Point(616, 8)

        Me.GroupBox1.Name = "GroupBox1"

        Me.GroupBox1.Size = New System.Drawing.Size(200, 184)

        Me.GroupBox1.TabIndex = 1

        Me.GroupBox1.TabStop = False

        Me.GroupBox1.Text = "Введите значенние"

        '

        'Label5

        '

        Me.Label5.Location = New System.Drawing.Point(56, 152)

        Me.Label5.Name = "Label5"

        Me.Label5.Size = New System.Drawing.Size(48, 16)

        Me.Label5.TabIndex = 9

        Me.Label5.Text = "B2"

        '

        'Label4

        '

        Me.Label4.Location = New System.Drawing.Point(56, 128)

        Me.Label4.Name = "Label4"

        Me.Label4.Size = New System.Drawing.Size(32, 16)

        Me.Label4.TabIndex = 8

        Me.Label4.Text = "B1"

        '

        'Label3

        '

        Me.Label3.Location = New System.Drawing.Point(48, 96)

        Me.Label3.Name = "Label3"

        Me.Label3.Size = New System.Drawing.Size(48, 16)

        Me.Label3.TabIndex = 7

        Me.Label3.Text = "Кол.гр"

        '

        'Label2

        '

        Me.Label2.Location = New System.Drawing.Point(48, 56)

        Me.Label2.Name = "Label2"

        Me.Label2.Size = New System.Drawing.Size(48, 16)

        Me.Label2.TabIndex = 6

        Me.Label2.Text = "Umax"

        '

        'Label1

        '

        Me.Label1.Location = New System.Drawing.Point(48, 24)

        Me.Label1.Name = "Label1"

        Me.Label1.Size = New System.Drawing.Size(56, 16)

        Me.Label1.TabIndex = 5

        Me.Label1.Text = "Umin"

        '

        'TextBox5

        '

        Me.TextBox5.Location = New System.Drawing.Point(128, 152)

        Me.TextBox5.Name = "TextBox5"

        Me.TextBox5.Size = New System.Drawing.Size(56, 20)

        Me.TextBox5.TabIndex = 4

        Me.TextBox5.Text = "3"

        '

        'TextBox4

        '

        Me.TextBox4.Location = New System.Drawing.Point(128, 120)

        Me.TextBox4.Name = "TextBox4"

        Me.TextBox4.Size = New System.Drawing.Size(56, 20)

        Me.TextBox4.TabIndex = 3

        Me.TextBox4.Text = "2"

        '

        'TextBox3

        '

        Me.TextBox3.Location = New System.Drawing.Point(128, 88)

        Me.TextBox3.Name = "TextBox3"

        Me.TextBox3.Size = New System.Drawing.Size(56, 20)

        Me.TextBox3.TabIndex = 2

        Me.TextBox3.Text = "4"

        '

        'TextBox2

        '

        Me.TextBox2.Location = New System.Drawing.Point(128, 56)

        Me.TextBox2.Name = "TextBox2"

        Me.TextBox2.Size = New System.Drawing.Size(56, 20)

        Me.TextBox2.TabIndex = 1

        Me.TextBox2.Text = "800"

        '

        'TextBox1

        '

        Me.TextBox1.Location = New System.Drawing.Point(128, 24)

        Me.TextBox1.Name = "TextBox1"

        Me.TextBox1.Size = New System.Drawing.Size(56, 20)

        Me.TextBox1.TabIndex = 0

        Me.TextBox1.Text = "350"

        '

        'Button1

        '

        Me.Button1.Location = New System.Drawing.Point(616, 208)

        Me.Button1.Name = "Button1"

        Me.Button1.Size = New System.Drawing.Size(96, 40)

        Me.Button1.TabIndex = 2

        Me.Button1.Text = "С полным замещением"

        '

        'Button2

        '

        Me.Button2.Location = New System.Drawing.Point(736, 208)

        Me.Button2.Name = "Button2"

        Me.Button2.Size = New System.Drawing.Size(96, 40)

        Me.Button2.TabIndex = 3

        Me.Button2.Text = "Неокласического типа"

        '

        'Button3

        '

        Me.Button3.Location = New System.Drawing.Point(616, 272)

        Me.Button3.Name = "Button3"

        Me.Button3.Size = New System.Drawing.Size(96, 48)

        Me.Button3.TabIndex = 4

        Me.Button3.Text = "С полным взаимодействием"

        '

        'Button4

        '

        Me.Button4.Location = New System.Drawing.Point(736, 272)

        Me.Button4.Name = "Button4"

        Me.Button4.Size = New System.Drawing.Size(96, 48)

        Me.Button4.TabIndex = 5

        Me.Button4.Text = "Смешанного типа"

        '

        'Button5

        '

        Me.Button5.Location = New System.Drawing.Point(688, 464)

        Me.Button5.Name = "Button5"

        Me.Button5.TabIndex = 6

        Me.Button5.Text = "Выход"

        '

        'Form1

        '

        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

        Me.ClientSize = New System.Drawing.Size(840, 509)

        Me.Controls.Add(Me.Button5)

        Me.Controls.Add(Me.Button4)

        Me.Controls.Add(Me.Button3)

        Me.Controls.Add(Me.Button2)

        Me.Controls.Add(Me.Button1)

        Me.Controls.Add(Me.GroupBox1)

        Me.Controls.Add(Me.PB)

        Me.Name = "Form1"

        Me.Text = "Form1"

        Me.GroupBox1.ResumeLayout(False)

        Me.ResumeLayout(False)

 

    End Sub

 

#End Region

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim Y1, Y2, U As Single

        Dim npos1, npos2 As Integer

        Array.Clear(SinX, 0, 10201)

        Array.Clear(sinY, 0, 10201)

 

        xn = CInt(TextBox2.Text) : xsh = CInt(TextBox3.Text) : xl = CInt(TextBox1.Text)

        npos1 = xsh

        For U = xn To xl Step -(xn - xl) / (xsh - 1)

 

            For Y1 = 0 To U / 2 Step U / 100

                Y2 = (U - 2 * Y1) / 3

                npos2 = (Y1 / (U / 100))

                sinY(npos1, npos2) = Y1

                SinX(npos1, npos2) = Y2

            Next

            npos1 -= 1

        Next

        построение_графика(SinX, sinY, CInt(xsh), "Y(1)", "Y(2)")

    End Sub

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim Y1, Y2, U, B1, B2 As Single

        B1 = CSng(TextBox4.Text)

        B2 = CSng(TextBox5.Text)

        Array.Clear(SinX, 0, 10201)

        Array.Clear(sinY, 0, 10201)

        Dim npos1, npos2, ограничение As Integer

        ограничение = 4000

        xn = CInt(TextBox2.Text) : xsh = CInt(TextBox3.Text) : xl = CInt(TextBox1.Text)

        npos1 = xsh

        npos2 = 0

        For U = xn To xl Step -(xn - xl) / (xsh - 1)

            Y2 = ограничение

            For Y1 = 0.1 To 10 Step 10 / 100

 

                If Y2 > ограничение Then

                    sinY(npos1, npos2) = Y1

 

                ElseIf Y2 < ограничение Then

                    npos2 += 1

                    sinY(npos1, npos2) = Format(Y1, "0.00")

                    SinX(npos1, npos2) = Format(Y2, "0.00")

                ElseIf Y2 = ограничение Then

                    sinY(npos1, npos2) = Format(Y1, "0.00")

                    SinX(npos1, npos2) = Format(Y2, "0.00")

                End If

                Y2 = (U / (Y1 ^ B1)) ^ (1 / B2)

            Next

            npos2 = 0

            npos1 -= 1

        Next

        построение_графика(SinX, sinY, CInt(xsh), "Y(1)", "Y(2)")

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Dim Y1, Y2, U, B1, B2, Ymax, Xmax As Single

        Dim npos1, npos2 As Integer

        B1 = CSng(TextBox4.Text)

        B2 = CSng(TextBox5.Text)

 

        Array.Clear(SinX, 0, 10201)

        Array.Clear(sinY, 0, 10201)

 

        xn = CInt(TextBox2.Text) : xsh = CInt(TextBox3.Text) + 1 : xl = CInt(TextBox1.Text)

        npos1 = xsh

        Xmax = xn * B1 * 3

        Ymax = xn * B2 * 3

        For U = 0 To (Xmax + Ymax) / 2 / 2.5 Step (Xmax + Ymax) / 2 / 2.5 / 100

            Y1 = B1 * U

            Y2 = B2 * U

            sinY(npos1, npos2) = Y1

            SinX(npos1, npos2) = Y2

            npos2 += 1

        Next

        npos2 = 0

        npos1 -= 1

        For U = xn To xl Step -(xn - xl) / (xsh - 1) ' количество графиков

 

            Y1 = 2 * U

            Y2 = Ymax

 

            sinY(npos1, npos2) = Y1

            SinX(npos1, npos2) = Y2

            npos2 += 1

 

            Y1 = 2 * U

            Y2 = 3 * U

            sinY(npos1, npos2) = Y1

            SinX(npos1, npos2) = Y2

            npos2 += 1

 

            Y1 = Xmax

            Y2 = 3 * U

            sinY(npos1, npos2) = Y1

            SinX(npos1, npos2) = Y2

            npos2 = 0

 

            npos1 -= 1

        Next

        построение_графика(SinX, sinY, CInt(xsh), "Y(1)", "Y(2)")

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Dim Y1, Y2, U, B1, B2, Ymax, Xmax As Single

        Dim npos1, npos2 As Integer

        B1 = CSng(TextBox4.Text)

        B2 = CSng(TextBox5.Text)

 

        Array.Clear(SinX, 0, 10201)

        Array.Clear(sinY, 0, 10201)

 

        xn = CInt(TextBox2.Text) : xsh = CInt(TextBox3.Text) : xl = CInt(TextBox1.Text)

        npos1 = xsh

        Xmax = xn * B2 + B1 * xn

        Ymax = xn * B1 + B2 * xn

 

        npos2 = 0

        'npos1 -= 1

        For U = xn To xl Step -(xn - xl) / (xsh - 1) ' количество графиков

 

            Y1 = B1 * U

            Y2 = Ymax

 

            sinY(npos1, npos2) = Y1

            SinX(npos1, npos2) = Y2

            npos2 += 1

 

            Y1 = B1 * U

            Y2 = B2 * U

            sinY(npos1, npos2) = Y1

            SinX(npos1, npos2) = Y2

            npos2 += 1

 

            Y1 = B2 * U

            Y2 = B1 * U

            sinY(npos1, npos2) = Y1

            SinX(npos1, npos2) = Y2

            npos2 += 1

 

            Y1 = Xmax

            Y2 = B1 * U

            sinY(npos1, npos2) = Y1

            SinX(npos1, npos2) = Y2

            npos2 = 0

 

            npos1 -= 1

        Next

        построение_графика(SinX, sinY, CInt(xsh), "Y(1)", "Y(2)")

лаб 3 рис 1.PNG

— 45.97 Кб (Скачать)

лаб 3 рис 2.PNG

— 46.37 Кб (Скачать)

лаб 3 рис 3.PNG

— 42.72 Кб (Скачать)

лаб 3 рис 4.PNG

— 44.47 Кб (Скачать)

код на 4 лабу модел экон.docx

— 22.36 Кб (Открыть, Скачать)

рис 4 1.PNG

— 59.89 Кб (Скачать)

рис 4 2.PNG

— 46.20 Кб (Скачать)

рис 4 3.PNG

— 47.77 Кб (Скачать)

рис 4 4.PNG

— 47.53 Кб (Скачать)

Лабораторная работа №4.xlsx

— 13.29 Кб (Открыть, Скачать)

Конспект лекций.pdf

— 740.17 Кб (Открыть, Скачать)

МоделирЭкон1.pdf

— 619.32 Кб (Открыть, Скачать)

МоделирЭкон2.pdf

— 349.29 Кб (Открыть, Скачать)

МоделирЭкон3.pdf

— 249.18 Кб (Открыть, Скачать)

МоделирЭкон4.pdf

— 221.67 Кб (Открыть, Скачать)

МоделирЭкон5.pdf

— 242.82 Кб (Открыть, Скачать)

ЛР №1 График.pdf

— 71.03 Кб (Открыть, Скачать)

ЛР №2 Элементы теории экстремума.pdf

— 404.99 Кб (Открыть, Скачать)

ЛР №3 Кривые безразличия.pdf

— 153.20 Кб (Открыть, Скачать)

ЛР №4 Теория потребления.pdf

— 119.86 Кб (Открыть, Скачать)

ЛР №5 Предельная полезность.pdf

— 95.27 Кб (Открыть, Скачать)

ЛР №6 Теория производства.doc

— 183.00 Кб (Открыть, Скачать)

Информация о работе Построение графика функции