LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

curve fit

Solved!
Go to solution

Hi altenbach and johnsold,

I have tried to fit a 2d array in the first loop. And as you said, I have indexed the array firstly and then plot the x-y graph. However, The x-axis of the curve is again the number of loop iteration from 0 to 13. However, the first column of the 2d array appears in the indicator as a probe locations of 1; 0.977; 0.955 ......0.284......0 etc. So, these values are not accepted as x-values by the specified program. But I want these values in the first column of the 2d array as x-values in the x-y graph and the second column of the 2d array as y-values. How can I achieve this? Could someone help to me? I have attached the picture that show the wrong x-y grpah according to identified 2d array elements and attached the last VI.

 

Please help me!!!! Thanks again to everbody who helps or does not help me!!!!

Download All
0 Kudos
Message 11 of 50
(1,863 Views)

As I already said, you need an xy graph. You also need to set the locations for the polynomial fit.

 

here's a cleaned up version, see if it makes sense to you.

Message 12 of 50
(1,851 Views)

Hi altenbach,

Thank you for your reply. I will try your solution and return back to you. Thanks again very much!!!

0 Kudos
Message 13 of 50
(1,829 Views)
Hi altenbach! I tried your solution. Now, it is ok. I am going to adapt it to my real world system. I have also another problem. The curve fit is ok. How can I use the equation that corresponds to this curve fit? For example, I will integrate this equation, or multiply it by a constant, etc. As a continuous process within the same VI, after curve fit, I want to process mathematically this equation corresponding the curve fit. I made lots of things for a week. But could not find any solution. Could you please help me for this situation?
0 Kudos
Message 14 of 50
(1,809 Views)

Use polynomial evaluation to calculate the function value for any possible x given the array of polynomial coefficients obtained earlier from the fit.

 

To graph an entire curve, create a ramp of x-values and do the same. See how far you get.

0 Kudos
Message 15 of 50
(1,797 Views)

Hi altenbach!

I see the polynomial evaluation. However, it is not likely suitable for that I want to do. I want to obtain the equation itself. For example, y=2.01x2 -1.0002x + 3.89. And then I will multiply this equation with 2pi and x variable and then integrate it. Later, I will divide the result to otner constant and obtain a mean value. Shortly, I need the equation purely in order to process it mathematically. I do not need to calculate the function value for any x value.

I need the function itself. Then, in the same VI, I will integrate and/or multiply/divide the function. Please help me!!

0 Kudos
Message 16 of 50
(1,789 Views)

 


mechen wrote:

I see the polynomial evaluation. However, it is not likely suitable for that I want to do. I want to obtain the equation itself. For example, y=2.01x2 -1.0002x + 3.89. And then I will multiply this equation with 2pi and x variable and then integrate it. Later, I will divide the result to otner constant and obtain a mean value. Shortly, I need the equation purely in order to process it mathematically. I do not need to calculate the function value for any x value.


 

LabVIEW does not do symbolic math and I don't really understand what you actually want to do. But I am sure a numeric solution would work and could be easily done.

 

Do you integrate over x? What range of x?

 

Message 17 of 50
(1,783 Views)

Hi altenbach,

 

I will integrate the equation over x in the range between 0 and 0.133. So, what I want is that:

 

Now, we are able to fit a curve for 2D x-y array. So, we have a function/equation for this fit. If I wire an indicator "General Polynomial Fit.vi" to "Polynomial coefficients", I can see the coefficient in array indicator. But, I want to take the equation as an output form the vi like this:      y=3x^2 + 2x -5             , etc. So, in the same vi, I will be able to process mathematically this equation. Firstly, ı will multiply this equation with x variable and the function will be   :   y=3x^3 + 2x^2 -5x   .    And then multiply it by 2*Pi. and it will be  y= 2*Pi*(3x^3 +2x^2 -5x)   . Then I will integrate it with respect to x variable in the range between 0 and 0.133 and find the flow rate as a value ,e.g., 0.234122 m3/s.

So, I need the function purely not only coefficients.  

0 Kudos
Message 18 of 50
(1,776 Views)
Solution
Accepted by topic author mechen

Try this. See if it makes sense.

Message 19 of 50
(1,769 Views)

Hi altenbach!

Thanks a lot for your reply. The program is now working very well. I have also one more question about write these result into a file. I tried it, however, somewhere I make mistake and do not succeed it. This is what I want:

I want to write a file like attached notpad. When I run the program and finish the run, I want to write the Reta, Reos, Frequency (f) and amplitude (A)  value as a file name.

 

on the other hand, in the file, I want to see r/R values and corresponding uta and uos values. Moreover, at the top of each values, I want their headings in the first row like r/R, uta, uos.

 

As a conclusion, e.g., If I want to see the data which belong to f=0.5 Hz, Reta=800, Reos=400 and A=1, etc.  , I will open the file named as "Reta=800; Reos= 400;f=0.5Hz;A=1". So, I will not make a mistake while searching the data form the data files.

 

Also, I want to store the pictures of best curve fits which are pointed in red circles in front panel picture in the attached file.

Could you please help me for these situations? Thanks again very much. I'm looking forward to hearing from you as soon as possible.

Download All
0 Kudos
Message 20 of 50
(1,733 Views)