- Community Home
- :
- Most Active Software Boards
- :
- Measurement Studio for VB6
- :
- Re: Need urgent help with Analysis.Math to calculate slope

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

11-30-2011 08:56 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

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!

12-01-2011 07:34 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

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

LabVIEW Student Ambassador

National Instruments UK

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

Options

12-01-2011 12:52 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

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

Product Support Engineer