LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a SubVI with selectable 1D or 2D array output (malleable VI)

Hi everyone,

 

I would like to create a SubVI that allows to import a matrix/vector from a binary file.

My problem is that the output could be a 1D or a 2D array (vector or matrix), depending on the number of columns I give in input to the SubVI (so if I have only 1 column, the output should be 1D, otherwise 2D).

 

I tried using malleable VIs and "variant", since I saw in one example that the output, in variant format, could be connected directly to a numeric indicator.

However, in my case I still get the problem that the output of my "malleable SubVI" cannot be directly connected to a numeric indicator. I found a solution only by adding the block "Variant To Data", which I would like to avoid in order to facilitate protability and usage by colleagues of the same SubVI and also because the LabVIEW examples do not need such conversion block.

 

Do you have any correction or suggestion about my VI (attached here)? Maybe with other solutions rather than malleable VIs?

Thank you!

0 Kudos
Message 1 of 3
(2,542 Views)
  • Why would it need to be a VIM if the input datatypes are always the same? VIMs adapt to datatypes, not values.
  • Why is the front panel and block diagram maximized to the screen? Very annoying!
  • Why don't you wire the I32 directly to the case structure and make one case "1" and the other "default"?
  • U64 is not a valid index (or size) input. Only the I32 range is usable.
  • Why do you divide instead of using Q&R?
  • What should happen if the number of elements is not divisible by the number of columns?
  • Why is the file input a string instead of path datatype? (and why is it called "directory" instead of "file").
  • Why do you use matrix transpose instead of regular transpose. It's a 2D array, not a matrix.
  • How exactly are you planning to use this in the caller? Why not just return a 2D array with one column? Once you have the variant, you still need to know what # is, so what's the point?
  •  
0 Kudos
Message 2 of 3
(2,527 Views)

Here's a quick draft what you could do (i.e. just use a "type" input where you wire a 1D or 2D DBL array. Probably still needs work to deal with unexpected inputs).

 

 

 

altenbach_0-1624557784832.png

 

 

0 Kudos
Message 3 of 3
(2,505 Views)