LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing n-dimensional array to sub-vi

Hello!

I need to pass a n-dimensional double array to a subvi, independently of
its sizes.

I don't want to use polymorphic vis, because this wouldn't be a solution, of course
(I CAN'T create "n" different vis if I don't know what n is 😉 )

How can I do?

Tnx!!
0 Kudos
Message 1 of 8
(5,471 Views)
You can convert every data to Variant to pass is and convert this again to data in SubVI.
Message 2 of 8
(5,468 Views)
Hi CAPITANEVS,
if you have your n-dimensional array in your sub vi, what do you make with it? How can you work with it without knowing the dimension?

Mike
0 Kudos
Message 3 of 8
(5,467 Views)
"I don't want to use polymorphic vis, because this wouldn't be a solution,...."
 
Care to expand on that point?
 
Have you concidered cast your data as a variant?
 
Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 8
(5,464 Views)
Another approach might be to reshape the array to 1D then pass the 1D array along with information about the number of dimensions and their sizes so the subVI could recreate the n-dimensional array.

Lynn
Message 5 of 8
(5,456 Views)

Hi CAPITANEVS,

you can also use the "Flatten to String" function to pass your data, but inside your vi, you have to create the constants for every dimension you think which can be passed, to unflatten it to the correct dimension. see the attached picture.

Mike



Message Edited by MikeS81 on 06-03-2008 06:38 PM
0 Kudos
Message 6 of 8
(5,455 Views)
I would go for lynn's solution (a 1d-array together with size info).
you could slice through the array to get the elements you want. (i will post one example later)

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 7 of 8
(5,406 Views)


CAPITANEVS wrote:
I need to pass a n-dimensional double array to a subvi, independently of its sizes.

For any given dimension the size is not an issue. Maybe you mean "independent on the number of  dimensions".
 
FIrst of all, I agree with Mike that sending the variable dimensional data to a subVI does not really help much, since you still need different code, one for each dimension.
 
What is a reasonable upper limit for the number of dimensions? I think the highest dimension I ever encountered was 4 or 5. A polymorphic VI for 1, 2, and 3 dimensions would probably be sufficient for almost everything, so a few polymorphic VIs should be sufficient.
 
Can you tell us a bit more about your application and why you think you need support for unlimited dimensions. What is the subVI supposed to do?
0 Kudos
Message 8 of 8
(5,395 Views)