# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## 2D array to 1d waveform

Using this function I can take a 2d array of data and change it into a 1d waveform array.

So a 7x100 array would give me 7 waveforms with 100 y values in each.

The dt would be the same and the starting time would be the same.

For some reason, when I use waveform graph it is plotting 7 waveforms, but only plotting 7 points for each.  It should be plotting however many Y values are in each waveform in my example 100.

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
Message 1 of 9
(4,409 Views)
Solution
Accepted by topic author eximo

## Re: 2D array to 1d waveform

Without any data saved in your VI, I can't tell how your array is setup.  You are using Array index to index out each row.  Perhaps you should be indexing out each column.

Also, your code could easily be done using a For Loop to auto-index through the waveform array and the 2-D array.  The only thing you might need to do is use Transpose Array before the For Loop to index out the correct dimension (columns vs. rows.)

Message 2 of 9
(4,390 Views)

## Re: 2D array to 1d waveform

(Sorry, posting by phone... Cannot see your code)

Just to graph your 2D array with the correct x-axis, all you need is bundle it with two scalars (x0, dx, 2D array) and wire it to the graph terminal. You could also wire the 2D array directly to the graph and set x0 and dx using property nodes.

Message 3 of 9
(4,376 Views)

## Re: 2D array to 1d waveform

Yes, that works, but why do I have a different result than the way I did it?  I feel like both should have produced the same graph.

(also, as alwyas thanks Altenbach, you may be right, but I don't fully understand what you are saying to do)

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
Message 4 of 9
(4,362 Views)

## Re: 2D array to 1d waveform

Pleast attach a VI that has typical default data in the 2D array.

(run VI so it contains data, right-click 2D array...make current values default...save VI under a new name and attach it here)

Whree does the array of waveforms come from? SInce you are overwriting most data, a scalar waveform diagram constant might be sufficient)

Message 5 of 9
(4,355 Views)

## Re: 2D array to 1d waveform

Here are three ways to graph a 2D array with the correct dx. No subVI needed.

Message 6 of 9
(4,345 Views)

## Re: 2D array to 1d waveform

@eximo wrote:

Yes, that works, but why do I have a different result than the way I did it?  I feel like both should have produced the same graph.

You say you have a 7x 100 array.  Without seeing data in a VI, I have no way of knowing if that is 7 columns by 100 rows, or 100 columns by 7 rows.

I'm going to guess the former.

You are grabbing 7 rows worth of data.  Since there are only 7 columns, you only get 7 datapoints per row.  So your 0th waveform is the 0th point of your 7 channels of data.  Your 1st waveform, is the 1st (0-based) point of the 7 channels.

If you wired a zero to the column input of the very first set of indices in your Index Array, then you would have grabbed the first 7 columns, each of which contains 100 rows of data.

Message 7 of 9
(4,335 Views)

## Re: 2D array to 1d waveform

If I unwire the Waveform input of that subvi everthing works fine.  Seems that I was not using that correctly?

Ravens Fan, I had tried to transpose the data or use it non transposed just in case I had a rows vs. columns issue.  However I wasn't getting the problem you would expect.

If i had it mistransposed I would have had 100 signals 7 points long, or 7 signals 100 points long.  I was having a problem getting 7 signals 7 points long.

The solution is above, but I'm trying to determine why the first method didn't work.

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
Message 8 of 9
(4,324 Views)

## Re: 2D array to 1d waveform

You were getting 7 signals 7 points long because you are only indexing out 7 waveforms (you dragged down the Index array to give you 7 outputs), but you were wiring up nothing to the index inputs, so that gave you each row of the 100 row x 7 column array by default.  Each row (and you are only grabbing the first 7 rows), gave you only 7 elements because there are only 7 columns.

If you don't believe it, then put some array indicators in your code expanded.  Also put in some array size functions and indicators on that so you can see exactly how big your arrays are at every step of the way.

Message 9 of 9
(4,305 Views)