From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

3D arrays in Mathscript on LabView 8.5.1

Solved!
Go to solution

Hi,

 

Can the Mathscript feature in Labview 8.5.1 handle 3D arrays and process the data accordingly? All of the arrays are generated within the Matlab script, analysed and processed as required and individual 1D numbers outputted back to Labview.

 

 

Thanks. 

0 Kudos
Message 1 of 7
(9,190 Views)
Solution
Accepted by topic author thomas_p
Hello,

At this time, MathScript cannot handle 3D arrays (either internally or when interfacing with LabVIEW).  We are aware of the limitation and hope to provide support in a future version.  Is it possible to accomplish what you want with multiple 2D arrays?

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 2 of 7
(9,185 Views)

Grant,

 

Thanks for the reply. I can accomplish the same tasks in 2D arrays but this doesn't make the code as efficient and obviously now requires multiple variables. It would be useful if LabVIEW and Mathscript could accommodate 3D arrays in the future. 

0 Kudos
Message 3 of 7
(9,180 Views)

On the subject of arrays, I've found another glitch in Labview's Mathscript, when compared to Matlab's operation. I'm not sure if this has already been reported, is known or has been fixed in LV8.6, so sorry if it's a duplicate report!

 

Say you have the following script in Matlab:

 

for n = 1:1:10

x = n^2;
y = x^2;
data_array(n,: ) = [n x y]; %Space added between : and ) because the forum turns that into a smilie!

end 

 

This works fine and generates a lovely 10x3 array, which gets progressively bigger with each iteration of the loop.

 

However, Labview generates the following error when running this: "Error in fuction '-' at line 4. The number of ruws and columns that the indexes specify must equal the number of rows and columns of values you want to set". The only way around this is to code the script as follows (or at least the only way I've found):

 

 for n = 1:1:10

x = n^2;
y = x^2;
data_array(n,1) = n;
data_array(n,2) = x;
data_array(n,3) = y;

end 

 

This obviously isn't overly efficient when you have ten or more columns, and then run the array-build through an IF loop to change the contents on certain conditions! Can anyone think of a better way of doing this that uses less lines of code?  

 

 

Cheers 🙂 

Message Edited by thomas_p on 04-18-2009 05:50 PM
Message Edited by thomas_p on 04-18-2009 05:50 PM
0 Kudos
Message 4 of 7
(9,161 Views)

Hello,

> It would be useful if LabVIEW and Mathscript could accommodate 3D arrays in the future.
LabVIEW can absolutely handle 3D (and higher) arrays.  It is only MathScript that cannot.

 

As for the other error you mention, I can't reproduce it in 8.5, so perhaps it is specific to 8.5.1.  It also seems to work properly in 8.6.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments

0 Kudos
Message 5 of 7
(9,144 Views)

lol you cant use 2D arrays to represent point clouds ie (x,y,z) ....  I want to manipulate pointclouds in a mathscript node 

0 Kudos
Message 6 of 7
(7,625 Views)

@Sentinal_Bais wrote:

lol you cant use 2D arrays to represent point clouds ie (x,y,z) ....  I want to manipulate pointclouds in a mathscript node 


Then this is something for the ideas exchange where new feautures can be proposed. It seems there already is an idea along these lines, and it did not get much support so far. Only 11 votes since January 2011.

 

I think it is easier to implement the algorithm in plain LabVIEW anyway. What do you need to do with these point clouds?

0 Kudos
Message 7 of 7
(7,619 Views)