LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

enforce restrictions for nonlinear curve fit

Solved!
Go to solution

Hello Forum users,

I'm currently working on a control VI that is supposed to create a specific pressure pattern inside a hollow tube to provide a testing environment for pressure Sensors. The details are numerous and complicated, so let's just say I'm pretty sure my formula to calculate this profile according to pressures inside hollow rings around this tube will work.

 

To find the correct pressure values for each ring I linked a model VI containing this formula to the Lev-Mar algorithm (nonlinear curve fit) and let it run.

Technically there are no problems and Lev-Mar does find values for fitting the function to the given values (not perfectly of course, but close enough).

 

The problem is, though, that, since the device, once suitable values for positioning and size of the rings are found, has to be constructed, the simulated pressure rings may not intersect with each other. To enforce this rule I added a check to my model VI, and if the values passed over from Lev-Mar break the rules, the model VI gives an array of zeros as its result (I tried an empty array, but that only leads to error messages).

This solution didn't work. Lev-Mar seems to ignore these cases and still finds values that break my rules (and if I put these values through my model VI, I get an array of zeros, as expected, so the check seems to work).

 

Maybe I misunderstood the Lev-Mar algorithm and it doesn't actually check each possible set of coefficients it finds.

 

Is there some way to fit any function to a set of values while keeping predefined boundary conditions?

 

Oh, before I forget:

I have to use LabVIEW version 8.2 in the insitute because the workshop systems don't have 8.5 installed for some reason.

 

Thank you in advance

Thaliur

0 Kudos
Message 1 of 3
(3,149 Views)
Solution
Accepted by topic author Thaliur

Hi Thaliur,

thanks for posting to our forums. 

 

As far as I understand your application you expect the algorithm to ignore a case of passing all zeros in the array. However, it is not implemented that way.

 

Good news is, its source code can be edited and you could save your own custom version of the algorithm VIs. It's up to you whether you just add a check for a array of zeros or simply pass another parameter that indicates a "rules broken" case. Then you would not have to continue the calculation. 

 

If I misunderstood your issue, please clarify this. You can also post some code for further explanation, if you wish.

 

Best of luck with the project!

 

Peter

--
Peter A.
Field Sales Engineer, NI Germany
0 Kudos
Message 2 of 3
(3,083 Views)

Thank you for the quick answer. You seem to have understood everything correctly.

 

I will try modifying the algorithm as you suggested. By now I found a suitable configuration by trial and error (I kept changing thestarting conditions for the fitting algorithm until the resulting pattern looked ok and didn't break the rules), so the coefficients can now be reduced to an array of 3 totally independent values, which will make everything a lot easier, but I'd like to keep a boundary-condition-ready version of Lev-Mar around, just in case 🙂

 

Now I just have to wait for the workshop and see if the values I got were right, so I should have some time for working on the modified code.

 

Thanks again

0 Kudos
Message 3 of 3
(3,064 Views)