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

cancel
Showing results for 
Search instead for 
Did you mean: 

The non-array

Hello,

I want to select multiple columns of an two dimensional array. My test
example is this:

1 2 3
4 5 6
7 8 9

I want to select columns 1 and 3 to get

1 3
4 6
7 9

It is easy to select the columns via a boolean array and a case in an
auto indexing for loop. But I didn't find any way to create an empty
array to reassemble the columns. I always get

1 0 3
4 0 6
7 0 9

This way the number of columns stays constant. I tried to use a non
initialized array constant and an array of length 0 in the false
(non selecting) case as a compulsory output. Cheating by using local
variables is no clean way of data flow programming.

I don't want to reinvent the wheel by reading the data from file as
text and chopping it up to provide empty strings in th
e right
places. I have to use the numeric values afterwards to subtract them
from the first row. Read from spreadsheet is the good way of doing it
but leads to the trouble with arrays.

Is there a clean way of doing it?

Johannes Niess
0 Kudos
Message 1 of 5
(2,694 Views)
I think you should use the array function: array subset (or something like
that) I presume you use LAbView 5.x or so.
The help-files give a perfect example of this function. After you created 2
1D-arrays, you can join them by the function build array.

Boozz.

please let me know if this is what you're asking

use: r.oude.vrielink@hetnet.nl

Grusse, ronald

Johannes Niess schreef in berichtnieuws
m2ogc1xma8.fsf@server.landtechnik.uni-bonn.de...
> Hello,
>
> I want to select multiple columns of an two dimensional array. My test
> example is this:
>
> 1 2 3
> 4 5 6
> 7 8 9
>
> I want to select columns 1 and 3 to get
>
> 1 3
> 4 6
> 7 9
>
> It is easy to select the columns via a boolean array and a case in an
> auto indexing for loop. But I didn't find any wa
y to create an empty
> array to reassemble the columns. I always get
>
> 1 0 3
> 4 0 6
> 7 0 9
>
> This way the number of columns stays constant. I tried to use a non
> initialized array constant and an array of length 0 in the false
> (non selecting) case as a compulsory output. Cheating by using local
> variables is no clean way of data flow programming.
>
> I don't want to reinvent the wheel by reading the data from file as
> text and chopping it up to provide empty strings in the right
> places. I have to use the numeric values afterwards to subtract them
> from the first row. Read from spreadsheet is the good way of doing it
> but leads to the trouble with arrays.
>
> Is there a clean way of doing it?
>
> Johannes Niess
0 Kudos
Message 2 of 5
(2,694 Views)
Ronald,

The core of the problem is that autoindexing only has one internal
variable for both input and output dimension. This behavior forces
array length (output):= array length (input)

It is easy to select the right parts. The problem is to reassemble the
selected pieces from a for/while loop.

Johannes Niess



"Boozz" writes:

> I think you should use the array function: array subset (or something like
> that) I presume you use LAbView 5.x or so.
> The help-files give a perfect example of this function. After you created 2
> 1D-arrays, you can join them by the function build array.
>
> Boozz.
>
> please let me know if this is what you're asking
>
> use: r.oude.vrielink@hetnet.nl
>
> Grusse, ronald
>
> Johannes Niess nn.de> schreef in berichtnieuws
> m2ogc1xma8.fsf@server.landtechnik.uni-bonn.de...
> > Hello,
> >
> > I want to select multiple columns of an two dimensional array. My test
> > example is this:
> >
> > 1 2 3
> > 4 5 6
> > 7 8 9
> >
> > I want to select columns 1 and 3 to get
> >
> > 1 3
> > 4 6
> > 7 9
> >
> > It is easy to select the columns via a boolean array and a case in an
> > auto indexing for loop. But I didn't find any way to create an empty
> > array to reassemble the columns. I always get
> >
> > 1 0 3
> > 4 0 6
> > 7 0 9
> >
> > This way the number of columns stays constant. I tried to use a non
> > initialized array constant and an array of length 0 in the false
> > (non selecting) case as a compulsory output. Cheating by using local
> > variables is no clean way of data flow programming.
> >
> > I don't want to reinvent the wheel by reading the data from file as
> > text and chopping it up to provide empty strings in the right
> > places. I have to use the numeric values
afterwards to subtract them
> > from the first row. Read from spreadsheet is the good way of doing it
> > but leads to the trouble with arrays.
> >
> > Is there a clean way of doing it?
> >
> > Johannes Niess
0 Kudos
Message 3 of 5
(2,694 Views)
What do you need for/while loops for?

In my opinion the question is as follows:

There's a 2D array:

123
456
789

You split it up into 2 1D arrays

1
4
7

and

3
6
9

And then the two 1D arrays are assembled into a 2D array.

13
46
79

Oder habe ich die frage nicht gut verstanden?

Ronald


Johannes Niess schreef in berichtnieuws
m2iu28vdam.fsf@server.landtechnik.uni-bonn.de...
>
> Ronald,
>
> The core of the problem is that autoindexing only has one internal
> variable for both input and output dimension. This behavior forces
> array length (output):= array length (input)
>
> It is easy to select the right parts. The problem is to reassemble the
> selected pieces from a for/while loop.
>
> Johannes Niess
>
>
>
> "Boozz" writes:
>
> > I think you should use the array function: array subset (or something
like
> > that) I presume you use LAbView 5.x or so.
> > The help-files give a perfect example of this function. After you
created 2
> > 1D-arrays, you can join them by the function build array.
> >
> > Boozz.
> >
> > please let me know if this is what you're asking
> >
> > use: r.oude.vrielink@hetnet.nl
> >
> > Grusse, ronald
> >
> > Johannes Niess schreef in berichtnieuws
> > m2ogc1xma8.fsf@server.landtechnik.uni-bonn.de...
> > > Hello,
> > >
> > > I want to select multiple columns of an two dimensional array. My test
> > > example is this:
> > >
> > > 1 2 3
> > > 4 5 6
> > > 7 8 9
> > >
> > > I want to select columns 1 and 3 to get
> > >
> > > 1 3
> > > 4 6
> > > 7 9
> > >
> > > It is easy to select the columns via a boolean array and a case in an
> > > auto indexing for loop. But I didn't find any way to create an empty
> > > array to reassemble the columns. I always get
> > >
> > > 1 0 3
> > > 4 0 6
> > > 7 0 9
> > >
> > > This way the number of columns stays constant. I tried to use a non
> > > initialized array constant and an array of length 0 in the false
> > > (non selecting) case as a compulsory output. Cheating by using local
> > > variables is no clean way of data flow programming.
> > >
> > > I don't want to reinvent the wheel by reading the data from file as
> > > text and chopping it up to provide empty strings in the right
> > > places. I have to use the numeric values afterwards to subtract them
> > > from the first row. Read from spreadsheet is the good way of doing it
> > > but leads to the trouble with arrays.
> > >
> > > Is there a clean way of doing it?
> > >
> > > Johannes Niess
0 Kudos
Message 4 of 5
(2,694 Views)
"Boozz" writes:

> What do you need for/while loops for?

My real data file is a lot bigger and numbers of columns and rows
vary. And IMO it is "natural" to use auto indexing and a boolean 1D
array to select columns.

>
> In my opinion the question is as follows:
>
> There's a 2D array:
>
> 123
> 456
> 789
>
> You split it up into 2 1D arrays
>
> 1
> 4
> 7

Array Subset icon #1

>
> and
>
> 3
> 6
> 9
>

Array Subset icon #2

> And then the two 1D arrays are assembled into a 2D array.
>
> 13
> 46
> 79

Its easy to do in a "parallel" approach. But it is unfeasible with big
number of varying columns. Thats why I need the loops. I'll attach a
minimum example in private mail to Roland and I can send it on request to
anyb
ody interested.

Johannes Niess
0 Kudos
Message 5 of 5
(2,694 Views)