05-10-2023 03:24 AM
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! 🙂
Solved! Go to Solution.
05-10-2023 03:34 AM
@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.
05-10-2023 03:42 AM
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.
05-10-2023 04:12 AM
Okay. I attached my VI. I have Labview version 2016
05-10-2023 04:39 AM
@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.
05-10-2023 04:40 AM - edited 05-10-2023 04:45 AM
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…)
05-10-2023 05:50 AM
See my 1st suggestion, just put the new element in front in the Build Array.
05-10-2023 06:24 AM
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"…
05-10-2023 07:00 AM
05-10-2023 09:52 AM - edited 05-10-2023 09:53 AM
@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.