Turn on suggestions

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

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Vindhyachal.Takniki

Member

06-20-2020 11:25 PM

Options

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

I have some chart in excel, where I get two values from measurment, lets say Va and Vb.

Now I need to find the best fit equation for it?

can labview do it?

Solved! Go to Solution.

06-20-2020 11:40 PM

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

Edit: wha ti wanted to know equation would be

C = some equation of (A,B)

A,B, & C values I know, want to find equation where I can put A&B values and get C from it.

cbutcher

Trusted Enthusiast

06-21-2020 12:06 AM

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

If you have only two points, you can fit basically anything to it.

The most common solution (and perhaps what you're asking for) is a linear fit - a straight line that goes through your two points with the equation "y = mx + c".

To solve for that equation, you'd want to write your results as follows:

Va = m * Xa (whatever your input is at measurement a) + c

Vb = (m * Xb) + c

Vb - Va = (m * Xa) + c - (m * Xb) - c = m * (Xa - Xb).

Since you know Xa and Xb and Va and Vb, you can calculate "m" from this.

Then, substitute into one of your starting equations to find c.

Now you have a linear equation that goes through your two points.

Note that this has nothing to do with LabVIEW - it's just algebra.

Implementing it in LabVIEW can be done with the nodes on the Numeric palette (i.e. subtract, multiply, etc).

You can also use a graph and something like a For loop to plot a line that highlights your solution.

For more complicated assumed equations, you can use more advanced tools like the Fitting VIs. However, for an equation of greater than linear complexity you'll need more than 2 points (results) to be able to solve it.

06-21-2020 05:05 AM

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

i have around 200 value sets where i know C,A,B

Need to form equaton, its not linear fit.

would be something like this I guess, but not sure. So what labview function for this?

cbutcher

Trusted Enthusiast

06-21-2020 05:43 AM

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

I think you probably want to take a look at this VI - it can be used generally to solve this kind of fitting problem: Nonlinear Curve Fit.

This page will give more information about its usage: Creating the Formula String or Fitting Model to Specify a Nonlinear Function.

Christian Altenbach gave a presentation about the use of this function (amongst others) that can be found here: slides. Unfortunately I can't find a video anymore...

altenbach

Knight of NI

06-21-2020 11:57 AM

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

@Vindhyachal.Takniki wrote:

i have around 200 value sets where i know C,A,B

Need to form equaton, its not linear fit.

would be something like this I guess, but not sure. So what labview function for this?

If you are not "sure", you need to fully research the problem until you are. Nobody can solve a "not sure" problem.

Your question makes no sense because your function shown does not even contain any C, A, or B.

- What are the model parameters?
- What is/are the independent variable(s)?
- What is the dependent variable?

How does the set of 200 C, A, B values look like? What does the data represent? What are you trying to learn from it?

Solution

Accepted by topic author Vindhyachal.Takniki

altenbach

Knight of NI

06-21-2020 12:15 PM

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

For simplicity, let's redefine C=z, A=x, B=y, so basically you have 200 scattered (xyz) points in space. If these points form some kind of unique plane where for any arbitrary [x,y] a "z" can be estimated, you can fit it to a model that describes this plane. It could be a higher order 2D polynomial or any other model based on an underlying theory. The plane is then defined by the set of model parameters (a0, a1, a2, aN) And for each arbitrary x,y points, a unique Z can be found based on the best fit parameters and a given [x,y]. Do the x,y point form a regular grid?

OTOH, if the model is discrete and only exists at the given x,y points, you could use a map (requires LabVIEW 2019 or newer!) serving as a lookup table. The key would be a 2D array containing x and y and the value would be z. (Be careful with any key datatype where equal comparisons are questionable (e.g. DBL))

06-23-2020 02:23 AM

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

Thanks @altenbach .

Sorted the issue

06-23-2020 02:42 AM

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

Can it be used to make equation where:

1. A= fun(x,y,z) where 4 paramters are known and need to make equation

2. Also in above equation generated is quite complex for low power MCU computation, any method where lesser order polynomial can be made.

In my case error margin of less than +-0.5 is acceptable.

altenbach

Knight of NI

06-23-2020 11:03 AM

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

@Vindhyachal.Takniki wrote:

Can it be used to make equation where:

1. A= fun(x,y,z) where 4 paramters are known and need to make equation

Yes, it can be expanded to any number of dimensions. The general technique stays exactly the same.

@Vindhyachal.Takniki wrote:

2. Also in above equation generated is quite complex for low power MCU computation, any method where lesser order polynomial can be made.

In my case error margin of less than +-0.5 is acceptable.

A polynomial in any number of dimensions is not "complex". A polynomial is generic and only defined by the number of terms. Start with low order, the increase the order until the result is withing the desired margins. If it still does not fit with a ~third order, maybe you need to create a model based on some theory.

It really depends on the data ±0.5 is excellent if the data is in the millions, but very poor if the data is in the nano or micro range.