LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cross product question

I am taking a cross product using the method I found on this forum; using an identity matrix and taking the determinant three times of a 3x3 matrix.  I am using the cross product so that I can find the XYZ components of the moments of multiple forces, store them in an array, and than add the components together to find the XYZ components of the resultant moment about some point.  The problem is that all of the determinants I am getting are coming back NaN.  I have included a screen shot of what I am working with.  Just so you know, the matrix going into the determinant is exactly what it should be, I made an indicator at one point to make sure.

0 Kudos
Message 1 of 7
(4,087 Views)

Hi dansdionne,

 

could you attach the vi with some data instead of a picture?

Before doing so you should also replace all those locals with wires and rethink your dataflow - atleast the "replace array subset" at the right seems wrong for me: reading from a local, writing several times to a different terminal and replacing each time a different item???

Message Edited by GerdW on 12-14-2008 09:51 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(4,066 Views)

Please dont mind the mess you are about to see.  I haven't cleaned/condensed the block diagram yet.  I just did the math step by step using a new frame for each step.  The last frame, finding the resultant moment, is the last step of the program.

 

The replace array subset on the right in the last frame is inserting 1D arrays into an empty array with dimensions 3x(number of cables) which I initialized a few frames before.

 

Also, the arrays on the front panel will not be showing when I am finished and are only for debugging.  You may have to right click to hide/show indicators if you cannot see something on the front panel.

0 Kudos
Message 3 of 7
(4,052 Views)

First of all using sub VIs in Labview is not prohibited, in fact it is recommended Smiley Wink This is a very common for people who are new to Labview. They use frames instead of sub VIs. I did to, but luckily my first programming was in Labview 3.1 and can not be opened in newer Labview versions.

 In the determinant calculation there are only multiplications and subtractions. So I guess the NaN is a result of previous calculations. Use the probe function and track the NaN source



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 4 of 7
(4,032 Views)
The matrix going into the determinant is all real numbers so it should work.  I can't figure out why it doesnt.  I suppose I will just do the multiplication and subtraction in a sub VI, but it would still be nice to figure out why this problem is occuring.  Thank you all for your responses.
Message Edited by dansdionne on 12-15-2008 03:20 PM
0 Kudos
Message 5 of 7
(4,003 Views)

I think you may have a race condition with all the local variables.  When I removed all except the Directions locals and wired things directly I get numbers.  Or there may have been a wiring error which I may have removed while cleaning up the diagram.

 

You do not need the sequence structure.  Everything can be handled by dataflow.

 

Lynn 

0 Kudos
Message 6 of 7
(3,988 Views)

Hi dansdionne,

 

The following suggestions may help you in pinpointing where you are getting the NaN output:

 

1.  The other posters are correct, you do not need to use a sequence structure if you wire things directly, dataflow will control the execution of the VI.

2.  Check to make sure the math before the cross product is correct, so that we can be sure the arrays contain the correct values before you are trying to calculate the cross product.  You can build a smaller VI and known inputs to make sure you are getting the correct values.

3.  Since you have created some user input stages (i.e. press next to continue) using the Express VI Prompt User for Input (Programming»Dialog & User Interface) would be a quick and easy way to get the basic info and it would clean up some of your block diagram.

4.  You can use Build Array to put together some of the values instead of using a local variable and insert into array. 

 

This post (http://forums.ni.com/ni/board/message?board.id=170&message.id=340069&query.id=145969#M340069) also includes another method for performing a cross product.

  

0 Kudos
Message 7 of 7
(3,952 Views)