LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any function that I can use to construct an n dimension array dinamically?

Hi, I want to construct an n-dimension array from an 1-dimension array.
The thing is: I have an 1-dimension array and, in a 'for' structure, I take a portion of that array in each iteration and I want to add each portion in each iteration in a different row of the n-dimensional array. Can any of you help me please?
Thanks you all,
0 Kudos
Message 1 of 7
(3,068 Views)
Hi,

you should slice the 1D array in sub-arrays and build a 2D array with them.

I attach a sample vi that shows how.

Good luck,

Alberto
0 Kudos
Message 2 of 7
(3,068 Views)
> Hi, I want to construct an n-dimension array from an 1-dimension
> array.

The LV diagram needs to know the dimensionality of the array at compile
time, but it is quite easy to append/replace items and subsets within
the array.

So, if you have an application that can produce a 2D, 3D, 4D, ... array
and you can't bound it, I'm really curious what this is doing, and you
are better off leaving the data in a 1D array and writing a cluster out
with it to give the encode and access information.

Presumeably a given diagram and loop will be working on one of these
sizes, lets say 3D. Drop down a Replace Subset node and wire the 3D
array into the top. The lower terminals will allow you to wire in the
information about what gets replaced. Be sure to read
the documentation
and look at some examples, as this is a powerful node that can replace a
single item, a 1D slice, a 2D slice, or a 3D subset. It might even be
better to make a small test VI with easy to recognize data and practice
a bit to get the hang of how you want to use it.

Greg McKaskle
0 Kudos
Message 3 of 7
(3,068 Views)
Hi Greg, thanks for your help, but I understand you suggest me to use the replace element function in witch I need to wire the data into the right terminal in each iteration. What I want is to have a 27D array from a 1D array, so I think maybe it won´t be a very elegant solution.
The reason I want such a big matrix is because I'm trying to analyse my signal by 1/3 octave analisys. But I don't find any function that I can use in the sound and vibration toolset for my purpose.
(Sorry about my english maybe is not very good)
0 Kudos
Message 4 of 7
(3,068 Views)
thanks Alberto, but that was not really my problem, maybe I didn't explain it very well, I have given on greg's comment further information, thanks anyway for your time
0 Kudos
Message 5 of 7
(3,068 Views)
> right terminal in each iteration. What I want is to have a 27D array
> from a 1D array, so I think maybe it won´t be a very elegant solution.

I doubt that you really need a 27dimension array, but I'm confident LV
will deal with it. To make a 27D array from a 1D array, drop the
Reshape Array node from the Array palette. Wire the 1D array to the top
left element, and grow the node to have 27 size entries. Start wiring
to tell LV the size of each dimension -- a 2x4x5x6x3x...x4x2x3x1x3x2
array -- and the wire coming out the right side will be the 27D array
using the elements from the 1D array.

Every other node, the replaces, inserts, will all need to be the same
dimensionality, so again, I suspect you will decide not to go this
rout
e, but this will get you a bit further down this road.

Greg McKaskle
0 Kudos
Message 6 of 7
(3,068 Views)
you are right, I have finally decided to follow another way of designing my program, thanks for your time anyway
0 Kudos
Message 7 of 7
(3,068 Views)