LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate Polynomial fit from Waveform graph

Solved!
Go to solution

Hello Everyone ,

 

I am new to lab-view hence would need a little assistance in one of the problem i am having right now .

 

My problem statement is : How to calculate Polynomial fit from Waveform graph data ? do i need to convert the waveform data to Graph XY and then use the built-in Polynomial Fit vi to calculate the fitting ?

 

Detail : My problem is that i have waveform graph , i am calculating the peaks and valley but due to noise , my detection of valley and peaks is sometimes not accurate , hence to smoothen the graph i need to apply Polynomial fit .

 

If anyone can help me in this , i will be very grateful .

 

Thank-you in advance

0 Kudos
Message 1 of 11
(6,034 Views)

OmarTariq,

 

SInce a waveform has equally spaced points you can easily create an X array with a for loop, dt, and the array size.

 

Lynn

 

20229i378178198EF58DEC

0 Kudos
Message 2 of 11
(6,026 Views)

thankyou for your reply and solution , it works ...

 

but i have a small question , suppose i am using Waveform graph value property node , i am getting values in an array not in waveform(dbl) format , how can i change my array of data into waveform(dbl) ?Sorry i know its a simple question but I am a student and am trying to work my way through labview

 

thanks in advance

0 Kudos
Message 3 of 11
(6,019 Views)

Hi Omar,

 

well, using IndexArray from the Array functions palette?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(6,015 Views)

Hello GerdW,

 

First of all i would like to thank you for reply. GerdW I know the IndexArray from the Array functions palette , but didn't understand the theme of your answer. Could you give me an example ?

 

I will once again explain my problem , I have a array of data from Waveform graph , i got this data by using the "Value" property node of waveform graph. Now i want to apply Polynomial fit on this array of data so that it would become smoother.

Hence making my graph smoother

 

Thankyou

 

 

0 Kudos
Message 5 of 11
(6,007 Views)

Hi Omar,

 

you have an array of waveforms and want to apply a fit to each of the waveforms? Use an autoindexing loop over that array...

 

Maybe you could attach a simple example instead of describing with words?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(6,002 Views)

 


OmarTariq wrote:

but i have a small question , suppose i am using Waveform graph value property node , i am getting values in an array not in waveform(dbl) format , how can i change my array of data into waveform(dbl) ?


 

If it is already an array, you don't need to do much. The value property of a graph will return the same datatype that you used to wire to it originally.

 

(If all this occurs in the same VI, it seems more appropriate to simply branch the wire going to the graph and do the analysis in parallel. A graph is not really meant for data storage.)

 

So, if there is a single 1D array you'll get that back out. All you need is also get x0 and dx from the property node to generate the actual x-array. If the graph contains a 2D array, use "index array" to slice out the desired trace.

 

Why don't you attach a simplified VI containing some actual default data in your graph. (Run your VI so it shows data, stop the VI, make current values default, save and attach the VI.)

 

What do you want to do with the polynomial fit? (e.g. simply also graph it on top of the real data in the same graph?)

0 Kudos
Message 7 of 11
(5,997 Views)

Thankyou everyone for your Replies , I really appreciate it

 

Okay i am attaching a demo vi which explains my problem plus a snapshot of my existing software which i am developing showing which kind of waveform i have and what i want to do.

 

As you can see in the picture , the wave has noise , i want to smoothen it up to get better results for detecting peak and valley .

 

 

Thanks in advance

Download All
0 Kudos
Message 8 of 11
(5,988 Views)
Solution
Accepted by topic author OmarTariq

Hi Omar,

 

have you seen Lynn's suggestion above?

 

You already have the Y values (your array). Now you need to build the X array the very same way as shown, only replacing the dt value with your point-to-point spacing. Somewhere in your code you know that value as you have a X axis shown in milliseconds...

20241i70AEC9121730144A

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 11
(5,981 Views)

Your example does not contain any data in the graph. One you have data, you need to make the current values the default before saving. (You can also right-click the graph and "Create constant". You should get a diagram constant with the data.)

 

It is silly to read the array from a value property node. Why so convoluted? As I said, simply wire to the polynomial fit instead of the graph, then graph both the fit and the data on the same graph.

0 Kudos
Message 10 of 11
(5,967 Views)