NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
Paulie Walnuts
Posts: 5
0 Kudos

Need urgent help with Analysis.Math to calculate slope

Hi all!

I am trying to use NationalInstruments.Analysis.Math to calculate the slope and intercept of a graph using VB. I'm using the CurveFit property but cannot find any resources regarding the applicable syntax. Any any help would be greatly appreciated.

 

Thanks in advance!

Member
Oli.P
Posts: 122
0 Kudos

Re: Need urgent help with Analysis.Math to calculate slope

Hi Paulie,

 

Have you had a look at the Getting Started guides for Measurement Studio?  There are versiosn for Visual Studio 2010, and Visual Studio 2005 and 2008.

 

This might also be useful.

 

I hope that helps.

 

Kind Regards,

Oli
LabVIEW Student Ambassador
National Instruments UK
Active Participant
D_Biel
Posts: 643
0 Kudos

Re: Need urgent help with Analysis.Math to calculate slope

Maybe you want something like this?

 

            Dim xArray() As Double = New Double(samples - 1) {}
            Dim dataArray() As Double = New Double(samples - 1) {}
            Dim fittedArray() As Double = New Double(samples - 1) {}
            Dim slope As Double
            Dim intercept As Double
            Dim residue As Double

            fittedArray = CurveFit.LinearFit(xArray, dataArray, FitMethod.LeastSquare, slope, intercept, residue)

 The LinearFit method has several overloaded methods, but the simplest one that still provides the slope and intercept output is:

 

Public Shared Function LinearFit ( _
	inputXData As Double(), _
	inputYData As Double(), _
	fitMethod As FitMethod, _
	<OutAttribute> ByRef slope As Double, _
	<OutAttribute> ByRef intercept As Double, _
	<OutAttribute> ByRef residue As Double _
) As Double()

 

National Instruments
Product Support Engineer
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page