LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mathscript transposing a 1D array???

Solved!
Go to solution

Hi,

I was having a problem with some Mathscript stuff but I found a workaround. Problem now is that I just don't understand why the workaround works...

 

I put a 1D column array into a Mathscript node and without doing anything to it, output it. BUT the output has been transposed. If I make it a 2D array but still with only values in the first column, this doesn't happen. Took me ages to figure this out but it doesn't really make sense to me why it would flip the 1D like that. I searched and all I got was this:

 

"The MathScript Node and the MATLAB script node handle 1D array inputs only by row"

from here: http://zone.ni.com/reference/en-XX/help/371361D-01/lvconcepts/scriptnodes/

 

Does that mean that anytime I want to use a 1D array with Mathscript I have to assume that no matter what it is going in, it's straight away going to get turned into a row by Mathscript? Is this a bug or is it on purpose? I've attached a VI to demonstrate it better than I can explain it.

 

I'm using 8.6 btw.

 

Thanks.

0 Kudos
Message 1 of 3
(3,035 Views)
Solution
Accepted by topic author RoBoTzRaWsUm
Hello,

This behavior is by design.  To understand this better, consider what you wrote: "I put a 1D column array into a Mathscript node..."  LabVIEW does not have the concept of row versus column arrays.  You can resize your T array to one element and then extend it horizontally.  This only changes the display of the data, not anything with the internal representation.  The help text you reference also gives the workaround of transposing the array once it is in the MathScript node, but like you discovered, working with 2D arrays will also workaround the problem.

You are correct: any 1D array going into a MathScript node will be treated as a row vector.  Again, since LabVIEW does not differentiate between the two, we made the choice to treat incoming arrays as row vectors in MathScript.  Treating them as column vectors would also be wrong 50% of the time, so unfortunately there is not much we can do until LabVIEW provides a way to specify the vector orientation.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
Message 2 of 3
(3,022 Views)

I'm pretty sure rows and columns don't matter in 1D arrays because you still index them with a single number.  You can drag out 1D arrays either horizontally or vertically when they are on the front panel.

 

Oh.  I guess it would matter in mathscript..

Message Edited by elset191 on 05-08-2009 11:00 AM
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 3 of 3
(3,021 Views)