LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When are we supposed to transpose?


@t.n14 wrote:

I was annoyed by this a while ago, too.

For me, most of the time I generate Data from measurments, a 1D Array of Data.

In a while loop this results in a 2D Array. If you put this in a for loop, you get your 1D Array of Data out!

Most of the time I want to make a mean Array of that measured Data, to get the Data of one Sensor I have to transpose it. That's my approach to this, thinking about the generation of that data to know how to get what I want.

I never worked with matrix or vectors, just saying.


We are getting a bit off-topic, because your commend is not really related to this particular discussion. If being "annoyed" forces you to actually read the help, that's a good thing!

 

From your description, I think you are confusing the default output tunnels of WHILE and FOR loops. It is not the type of loop, but the type of output tunnels (indexing, last value, concatenating) that will determine what you get at the outside of the loop.

 

Measurements are just data (scalar, 1D array, 2D array, etc. ) 

Message 11 of 17
(516 Views)

@altenbach wrote:
We are getting a bit off-topic, because your commend is not really related to this particular discussion. If being "annoyed" forces you to actually read the help, that's a good thing!

Sorry to confuse you here, my reply was about the thread title and the beginning of the post, what looked to me more general. I just tried to help with a simple text, that helped me. Sometimes it's all you need/want.

0 Kudos
Message 12 of 17
(505 Views)

@t.n14 wrote:

@altenbach wrote:
We are getting a bit off-topic, because your commend is not really related to this particular discussion. If being "annoyed" forces you to actually read the help, that's a good thing!

Sorry to confuse you here, my reply was about the thread title and the beginning of the post, what looked to me more general. I just tried to help with a simple text, that helped me. Sometimes it's all you need/want.


Well, the sentence:

 

"In a while loop this results in a 2D Array. If you put this in a for loop, you get your 1D Array of Data out!"

 

was pure gibberish. 😄 It is not possible to imagine what that all means without actually seeing some code.

0 Kudos
Message 13 of 17
(493 Views)

It took a while, but here it is 😉

 

In my projects and measurements, every second I get all current values of all my sensors (temperature, pressure, humidity) at once. I.e. an array of 3 values, to calculate a average over 180s I put them in a while loop for that time.

A long time I was always confused of what will be used first, rows or columns, now I only think of how the dimensions were put together, the reverse way they will be striped down.

With my measured array of all sensors (2D Array: 180 values for each of the 3 sensors), put in a for loop, every iteration I get an array of one value for each sensors, that is what I put in. To get every measured value of one sensor (each iteration) I have to transpose it.

tra or not 2 tra.png

Thats the way I remember it, thinking about rows and columns confuses me every time -.-'

0 Kudos
Message 14 of 17
(427 Views)

I think NI has paragraphs about building arrays and rows and columns, and after reading the first paragraph, I decided I wasn't ever going to remember it, so I just cheat and make a probe or an indicator and look at the data.  Kind of like what you are doing, actually, but mine no longer needs to be so involved.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 15 of 17
(413 Views)

@t.n14 wrote:

A long time I was always confused of what will be used first, rows or columns, now I only think of how the dimensions were put together, the reverse way they will be striped down.

With my measured array of all sensors (2D Array: 180 values for each of the 3 sensors), put in a for loop, every iteration I get an array of one value for each sensors, that is what I put in. To get every measured value of one sensor (each iteration) I have to transpose it.


Sorry, that's just a lot of gibberish, because I am not familiar with terms such as "striped down".

 

All arrays (any number of dimensions!) are stored linearly in memory and in the order of indices. (have a look at our presentation, part 2). Any transpose operation requires rearranging all elements in memory unless the compiler can avoid it by tagging it as "transposed" forcing further operations to just swap indices when accessing).

 

Taking an average of 180 values of three sensors does not require transposition and fancy array shuffling, it can be done in-place without ever going to 2D arrays using pbypt techniques. If you need help with that, please start a new thread.

0 Kudos
Message 16 of 17
(407 Views)

@altenbach wrote:

All arrays (any number of dimensions!) are stored linearly in memory and in the order of indices. (have a look at our presentation, part 2). Any transpose operation requires rearranging all elements in memory unless the compiler can avoid it by tagging it as "transposed" forcing further operations to just swap indices when accessing).


Is this really true? I have always avoided transpose for large arrays as it seems like a memory copy is always made. The show buffer "dots" also always show a black dot on a transpose operation.

0 Kudos
Message 17 of 17
(384 Views)