LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can you perform curve fitting to a 2d array and find the maximum?

Where did you have that example tucked away, altenbach? Smiley Very Happy

While trying to provide a response I had come across this other example you had, which looks like an early version of this one. However, it, like this one, requires a mathematical model, and my assumption (right or wrong) was that the user didn't have one so I didn't mention it. Instead, I opted to suggest just the raw polynomial curve fit. Still, I should have suggested that example regardless in case the user did have a mathematical model. Thanks for pointing it out.


0 Kudos
Message 11 of 32
(3,972 Views)

smercurio_fc wrote: Where did you have that example tucked away, altenbach? Smiley Very Happy
I submitted it to NI, so it should be available somewhere as part of the NI-week extras. I was just looking at it and found that there is a problem, possibly with the 3D graph activex component and I get a crash under some conditions (under 8.5.1). I want to research this first before posting here again.
 
 
If you look at the other link I posted (3DPoly_Newdata.llb), it does a plain 2D polynomial of arbitrary order (See picture).
 


Message Edited by altenbach on 06-27-2008 10:40 AM
Message 12 of 32
(3,966 Views)
Just to make sure I understand...

Take a string of my X positions separated by spaces, and put that into the phi input. Same with Y pos into alpha, and associated measurements into the yaw, and I should be able to get the mathematical model displayed for me?
0 Kudos
Message 13 of 32
(3,960 Views)
Well, all you need is three 1D DBL arrays of equal lenght (x, y, z) and substitute for the three 1D arrays that come out of the index array connected to the "select x, y, z" controls. The rest should fall into place. (e.g. delete the two "index array", turn CurrentX, CurrentY, CurrentZ into controls. and wire in your array data in some way.
 
There is currently al lof of extra code to be able to select any of 4 choices for any of the 3 axes. (bug alert: there are even a few wires missing!, e.g. going to the idexing of the axis names).
 
Anyway,  you don't need all that!
 
As I said, since your x and y form a regular grid, things could be simplified further. All you need is X0, dx, Y0, dy, and a 2D Y array. This would require some reworking though. 😉
0 Kudos
Message 14 of 32
(3,954 Views)
Yeah I think what I'll end up doing is reworking my own code to make 3 files. One to write the current X position to, one to write the current y position to, and one for the measured value. Then it should be easy enough to wire those directly to the three inputs.

Thank you very much for your help.
0 Kudos
Message 15 of 32
(3,951 Views)
I also need a great amount of accuracy with the measurement inputs, though it only looks like it can handle to two decimal points. I've looked through your code, but cannot find where it makes this cutoff. Any idea where this might be happening?
0 Kudos
Message 16 of 32
(3,931 Views)
The calculations is done in full DBL precision. If you want to see more, right-click the indicators and change the dislpay format to show more digits.
 
0 Kudos
Message 17 of 32
(3,929 Views)
Ah, thank you.

The algorithm also seems to be calculating beyond the number of points that I want it to. I attached a picture so you can see what I mean.

Beyond the domain of the information I'm inputting, it is still calculating best fit. So I'm guessing that it thinks I'm also inputting a value of (x y z) = (0 0 0), which kind of stinks...
0 Kudos
Message 18 of 32
(3,926 Views)


jaysmall wrote:
Beyond the domain of the information I'm inputting, it is still calculating best fit. So I'm guessing that it thinks I'm also inputting a value of (x y z) = (0 0 0), which kind of stinks...

You actually are, look at the arrays. You need to remove the elements that are zeroes and truncate the arrays. Where are the zeroes coming from? Do you have extra empty lines in your datafile perhaps?


Message Edited by altenbach on 06-27-2008 02:45 PM
0 Kudos
Message 19 of 32
(3,914 Views)
I'm not putting those in, the string I pass it ends. But if you scoll down on the front page to the end of your inputs, and then continue scrolling, you can see that there is an endless string of inputs of (x y z) = (0 0 0)

Hopefully if I can get this one, it will be the end of my issues since everything else seems to be working. Then it's on to find the local maximas...
0 Kudos
Message 20 of 32
(3,910 Views)