LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate sigma notation in LV?

Greetings,
 
I am looking for a method to calculate Sigma notation (see attachment) in LV. I cannot seem to find a way using MathScript to do this.
 
I already attempted to manually write out code to process these formulas, but my results are offtrack (that's a seperate issue.... if someone would like to attempt to debug my code, let me know and I'll post it). 
 
Any ideas?
 
Thanks.
 
-Ryan
0 Kudos
Message 1 of 13
(4,700 Views)
We cannot debug your code unless you attach it ;).
0 Kudos
Message 2 of 13
(4,688 Views)


We cannot debug your code unless you attach it


...agreed...
 
So then, I humbly submit my work for review.
 
The theory I'm working on here is finding a best-fit plane through some data. So we enter a bunch of points (XYZ's), and plot them to show what they look like. Then we calculate the best-fit plane, and plot it. The two planes should appear to be identical.
 
I'm also using a 3D control to draw the points in planar form. The first chart is built from the numbers directly to the right of it. The default numbers in the "Input array" are known to be on a common plane (not a normal condition for this program, but for a formula proof, this was easiest).
 
The second chart is the "Calculated" best-fit plane. The actual XYZ's are shown in the array to the right, but they are of little use to the operator.
 
Notice I took the step of making the X, Y, and Z scale on both charts all into a 1:1 (1:1:1...?) ratio. With that taken into consideration, the plane on the first chart should like very similar to the plane on the second chart (the compound angles should be identical, but the physical size and positioning in the chart are immaterial).
 
The third tab shows the raw data from the calculations.
 
 
 
Block diagram (don't laugh; this was only meant to be a formula proof only!):
 
Specifically. I'm looking for someone to verify if I'm calculating Sigma properly. You will see notations in the formula (string-constant boxes with numbers in them... the numbers correlate to the numbers on the indicators....so that the area of the formula with the "1" notation will have the result shown in the "1" indicator, etc.). I think the theory of plotting the data is in good shape.
 
As you can see by executing the VI....the two planes currently do not match.
 
Any help that can be provided will be greatly appreciated.
 
-Ryan

Message Edited by RWiersma on 10-30-2006 09:47 AM

0 Kudos
Message 3 of 13
(4,661 Views)
Your use of sigma seems fine.  Whether the symbol in question is a plus sign or a multiplication sign is anybody's guess.  It looks like a +, but if it were, it should be bigger like the minus sign.  If it is * (multiply), it surely isn't needed, so why is it there?  Try using input data where you can predict the outcome.  Then try the formula with + and with * to see which looks right.  Or look for another source for the formula.  Maybe it would be more readable.
- tbob

Inventor of the WORM Global
Message 4 of 13
(4,644 Views)
I've just looked over your code quickly, but one problem I see is that you aren't passing "N" to your cluster.  The default is 4.  I tried to plot some data and the result still isn't correct.
Message 5 of 13
(4,608 Views)


@RWiersma wrote:

The theory I'm working on here is finding a best-fit plane through some data.

Well, then this should have been the title of your thread! 😄

Whatever you are doing is extremely tedious! You can just use general LS fit and do it with some simple code the size of a postage stamp. 🙂

Long ago I wrote a much more complicated demo (fitting points to a 2D polynomial plane of arbitrary order) and it would be trivial to adapt it to your problem, just delete 90% of the code and only leave order=1 ;).

Check out my old demo: http://forums.ni.com/ni/board/message?board.id=170&message.id=129944#M129944

(Ignore the Levenberg-Marquardt alternative code).

Message 6 of 13
(4,601 Views)
OK, here's a quick draft, using my old 2D polynomial function set to n=1. If you want, you can hardcode them for a simple plane.
 
See if this makes sense to you. 🙂
 
It probably needs more work....
Message 7 of 13
(4,592 Views)


I've just looked over your code quickly, but one problem I see is that you aren't passing "N" to your cluster.  The default is 4.  I tried to plot some data and the result still isn't correct.

Ahh yes... good spot! Wish I could turn on uninitialized-variable notification or something (ala Option Explicit, in VB). Thanks for the note.
0 Kudos
Message 8 of 13
(4,570 Views)


@altenbach wrote:
OK, here's a quick draft, using my old 2D polynomial function set to n=1. If you want, you can hardcode them for a simple plane.
 
See if this makes sense to you.
 
It probably needs more work....



Wow. That's a very pleasant surprise 🙂 I figured there was a better way to do this, but I just didn't know what I was looking for.

It looks like you nailed it. I can work with this, quite likely.

I greatly appreciate your time and assistance!

 

 

Message Edited by RWiersma on 11-02-2006 08:44 AM

0 Kudos
Message 9 of 13
(4,566 Views)


@altenbach wrote:
OK, here's a quick draft, using my old 2D polynomial function set to n=1. If you want, you can hardcode them for a simple plane.
 
See if this makes sense to you. 🙂
 
It probably needs more work....



Now the next question is.... can this module report flatness of the cloud? I guess...that would be residue from the plane-to-data fit, but I don't see a residue output.

Any suggestions?

0 Kudos
Message 10 of 13
(4,537 Views)