2017-12-23 7 views
1

VB.Net에서 플롯해야하는 방정식이 있습니다. 이 라이브러리, MATH.Net을 찾았습니다. C#에는 많은 예제가 있습니다.vb.net에서 다항식을 그릴 때 Math.NET 라이브러리 사용

이 라이브러리를 사용하여 VB.NET에서 다항식 함수를 플로팅 할 수 있습니까?

그렇다면 어떻게됩니까? 인터넷에서 예제를 찾을 수 없었습니다. 그렇지 않다면 아무도 VB.Net의 그래프에 다항식을 그리는 방법에 대한 안내를받을 수 있습니까?

저는 Visual Studio 2010을 사용하고 있으며 Visual Basic (계산기 같은 간단한 응용 프로그램을 만들었습니다)에 대한 경험이 거의 없습니다.

+0

를 생성 도표. [차트 컨트롤의 시리즈 및 데이터 포인트] (https://msdn.microsoft.com/en-us/library/dd456769.aspx)에는 시작할 때 사용할 용어가 충분히 소개 될 수 있습니다. –

+0

질문이 왜 부정적인 평가를 받았습니까? 많은 사람들이이 대답을 찾고 있습니다.이 질문은 여러 VB 및 .NET 포럼에서 답변을 얻지 못했습니다. 심지어 Visual Studio 포럼의 ... –

+0

질문이 나를 잘 봐, upvoted! 일반적으로 일부 SO 편집기는 이미 시도한 코드의 일부 코드를보고 싶어합니다. 그러나이 경우에는 관련성이없는 것처럼 보입니다. – not2qubit

답변

2

일부 데이터 요소를 생성하여 차트의 시리즈에 추가하십시오. 예를 들어

,

Imports System.Windows.Forms.DataVisualization.Charting 

Public Class Form1 

    Function Polynom(x As Double) As Double 
     Return Math.Pow(x, 3) + Math.Pow(x, 2) + x 
    End Function 

    Function Polynom2(x As Double) As Double 
     Return 3 * Math.Pow(x, 2) + 2 * x + 1 
    End Function 

    Sub CreateChart() 
     Dim xMin = -2.0 
     Dim xMax = 2.0 
     Dim nPoints = 21 
     Dim xInc = (xMax - xMin)/(nPoints - 1) 

     Dim c As New Chart 
     c.Size = New Size(Me.Width * 0.9, Me.Height * 0.9) 
     c.Series.Clear() 

     Dim ca As New ChartArea With {.Name = "ChartArea1"} 
     ca.AxisX.Title = "variable" 
     ca.AxisY.Title = "dependent variable" 
     ca.AxisX.Minimum = xMin 
     ca.AxisX.Maximum = xMax 

     c.ChartAreas.Add(ca) 

     Dim s1 As New Series 
     s1.Name = "Polynomial" 
     s1.MarkerStyle = MarkerStyle.Circle 

     Dim s2 As New Series With { 
      .Name = "Derivative", 
      .MarkerStyle = MarkerStyle.Diamond, 
      .ChartType = SeriesChartType.Line 
      } 

     For i = 0 To nPoints - 1 
      Dim x = xMin + i * xInc 
      s1.Points.AddXY(x, Polynom(x)) 
      s2.Points.AddXY(x, Polynom2(x)) 
     Next 

     c.Series.Add(s1) 
     c.Series.Add(s2) 
     c.Series("Polynomial").ChartType = SeriesChartType.Line 

     Dim lgnd As New Legend With {.Name = "Legend"} 
     c.Legends.Add(lgnd) 
     lgnd.DockedToChartArea = "ChartArea1" 
     lgnd.Docking = Docking.Top Or Docking.Left 
     s1.Legend = "Legend" 
     s2.Legend = "Legend" 

     Me.Controls.Add(c) 

    End Sub 

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 
     Me.Size = New Size(640, 480) 
     Me.Text = "Simple polynomial plot" 
     CreateChart() 

    End Sub 

End Class 

는 그냥 데이터 포인트를 생성에 시리즈에 추가 할 필요가 차트에 다항 함수의 그래프를 플롯

enter image description here