07-29-2010 06:49 AM
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
Solved! Go to Solution.
07-29-2010 07:42 AM
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
07-29-2010 08:05 AM
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
07-29-2010 08:20 AM
07-29-2010 08:32 AM
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
07-29-2010 08:34 AM - edited 07-29-2010 08:35 AM
07-29-2010 08:36 AM
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?)
07-29-2010 09:02 AM
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
07-29-2010 09:08 AM
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...
07-29-2010 10:11 AM
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.