LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with 2D array: shifting rows

Solved!
Go to solution

Hello,

 

There's an 2d array.

number of rows: 3

number of columns: 5

 

How can i make the lates measurement row be always on top? Rows sould be shifted down as filling row. Like this:

 

n

n-1

n-2

 

Is there a sample for this problem in labiew?

 

It may sound easy, but i got stuck, help me please! 🙂

0 Kudos
Message 1 of 12
(1,586 Views)

@LTBALAZS wrote:

Hello,

 

There's an 2d array.

number of rows: 3

number of columns: 5

 

How can i make the lates measurement row be always on top? Rows sould be shifted down as filling row. Like this:

 

n

n-1

n-2

 

Is there a sample for this problem in labiew?

 

It may sound easy, but i got stuck, help me please! 🙂


If you want this to be a learning experience and not just a quick fix, why don't you upload the VI you are having issues with so we can show you what's happening and how to fix it.

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 2 of 12
(1,581 Views)

If you use Build array, just add in front. 

If you have some time number in one of the columns, you can use Sort 2D array by that number.

You can set a 'ordering column' and use Sort 2D array. In this case it's easiest to start with a high number and go -1 for each.

You can create a temporary queue and loop through it with Add in opposite end, then Flush.

You can to a Replacement loop where you extract the 1st and Last element and use Replace Array Subset to switch them, continue with 2nd and 2nd to last until you've looped through half the length of the array.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 12
(1,576 Views)

Okay. I attached my VI. I have Labview version 2016

0 Kudos
Message 4 of 12
(1,561 Views)

@LTBALAZS wrote:

Okay. I attached my VI. I have Labview version 2016


I will give you an hint to achieve your program.

 

Use Initialize 2Darray[3*5], Insert Into Array and Delete Array, With this you can achieve your requirement easily.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 12
(1,546 Views)

Hi LTBALAZS,

 


@LTBALAZS wrote:

There's an 2d array.

number of rows: 3

number of columns: 5

 

How can i make the lates measurement row be alway


What is the "latest measurement" when the 2D array is built from exactly 3 rows each 15th iteration of the while loop???

 

Why were there so many orange wires when you should count iterations using integers???

 

Suggestion:

Instead of creating 3 rows each 15 iterations you should create just one row (of 5 elements) each 5 iterations.

Then just prepend that new row to your 2D array (and use one more shift register to hold your 2D array)…

 

@Palanivel:

Use Initialize 2Darray[3*5], Insert Into Array and Delete Array, With this you can achieve your requirement easily.

Don't start to fiddle with InsertIntoArray/DeleteFromArray when you just want to prepend rows to a 2D array!

(You better point out that prepending to a growing 2D array will let the LabVIEW memory manager go havoc after a while…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 12
(1,544 Views)


 

See my 1st suggestion, just put the new element in front in the Build Array.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 12
(1,521 Views)

Hi Yamaeda,

 


@Yamaeda wrote:


See my 1st suggestion, just put the new element in front in the Build Array.


This will create new columns in front of the older ones, but not "new rows above the old ones"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 12
(1,511 Views)

@GerdW wrote:

Hi Yamaeda,

 


@Yamaeda wrote:


See my 1st suggestion, just put the new element in front in the Build Array.


This will create new columns in front of the older ones, but not "new rows above the old ones"…


Right! I answered too fast. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 12
(1,499 Views)

@LTBALAZS wrote:

Okay. I attached my VI. I have Labview version 2016


Sorry, I don't see what this code has to do with the original questions. You are building a pseudo-ragged 2D array where each row grows independently, then formed into a 2D array padded to the longest row.

 


@LTBALAZS wrote:

There's an 2d array.

number of rows: 3

number of columns: 5

 

How can i make the lates measurement row be always on top? Rows sould be shifted down as filling row. Like this:

 

n

n-1

n-2

 

Is there a sample for this problem in labiew?


What is a "measurement"? (one row? one scalar appended to one of the rows depending on value? something else?).

 

95% of solving a problem is fully defining it! Your specs are way too vague! Does your attached Vi work correctly or not? Explain exactly what you want to see as a function of iterations.

0 Kudos
Message 10 of 12
(1,451 Views)